Customized buttons on C#

Started by
3 comments, last by kSquared 19 years, 5 months ago
Um... I was wondering how to make customized buttons in C#. Lets say I want to make a round button. How do I do that? I'm not that much good of a programmer so it would be great if anyone could show even a short code or part of code that shows how to.
Advertisement
What you're looking for is called "owner drawing." You basically override the default paint commands for a control and provide your own.

The best resource I could point you to would be the RegionMaster controls on WindowsForms.net. They include the source code and are fairly well documented so with a little time and effort you'll be up and running.

G'luck.
..what we do will echo throughout eternity..
For nonstandard or weird-shaped buttons, you have to draw them yourself. Check out the helpfiles on the OwnerDraw property.

The simple (but cruder and less efficient) way is to put a transparent PictureBox on your form with the image of the button you want. Then override the mouse events to make the "button" respond appropriately (changing color when the mouse is hovering, becoming depressed when you click it, etc.).
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Quote:The best resource I could point you to would be the RegionMaster controls on WindowsForms.net. They include the source code and are fairly well documented so with a little time and effort you'll be up and running.


Waaahhhh!!! I can't understand a single line of code!! And also my version of VS .NET is much older and I can't open the solution file.

Isn't there another much more "simpler" way of doing it?
The simplest way I know of is the one I mentioned, I'm afraid. Owner-drawing isn't easy, but it's not too hard either. Take some time to read up on it (CodeGuru will have some articles, most likely), or try posting over on the msdn message boards.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}

This topic is closed to new replies.

Advertisement