Sign in to follow this  
romainechester

Customized buttons on C#

Recommended Posts

romainechester    122
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.

Share this post


Link to post
Share on other sites
Talonius    643
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.

Share this post


Link to post
Share on other sites
kSquared    1356
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.).

Share this post


Link to post
Share on other sites
romainechester    122
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?

Share this post


Link to post
Share on other sites
kSquared    1356
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this