Click here to Skip to main content
15,887,871 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I tried to find some ready code, but I failed. it would be enough for me, if someone explain the process of creatiojn. Is radiobutton merged two controls or just a modified label?
Posted
Comments
Ubloobok 16-Jun-11 10:01am    
If you about the control template:
RadioButton is two or more controls. Main parts are:
1) Some UIControl which displays that button has been ckecked (clicked).
2) ContentPresenter which displays content.


You may see on the MSDN inheritance hierarchy for more understanding:
http://msdn.microsoft.com/en-us/library/system.windows.controls.radiobutton.aspx
BobJanova 16-Jun-11 10:31am    
WinForms or WPF? (I think there is a cut down version of both in there.)
Drazen Pupovac 16-Jun-11 10:57am    
WinForms

Thanks for the answer.
Sergey Alexandrovich Kryukov 16-Jun-11 15:02pm    
Tag it! Don't torture experts trying to find out what is that! If should be visible before opening the page with the question.
--SA
Ubloobok 16-Jun-11 10:42am    
Sorry, i thought about the WPF.

WinForms radio buttons are standard Windows controls, and therefore it's quite difficult to perform small extensions on them.

A radio button, button and text together, is one control. If you want to change its appearance, you can override OnPaint, but you need to draw both parts.

I found an example here[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 15:07pm    
Good point, all correct, my 5. But... what to do with that, except for leaving things as they are? Inferring the logical conclusion for a next step is apparent...

Please see my solution.
--SA
By the reasons Bob correctly pointed out, right solution would be the following:

Create your own radio button control, a completely custom one. Derive your class right from System.Windows.Forms.Control, override OnPaint to render its appearance depending on states, etc. Use System.Windows.Forms.Control.Invalidate on the change of state or any other properties affecting control appearance.

With System.Windows.Forms, this is pretty simple task.

—SA
 
Share this answer
 
Comments
Espen Harlinn 16-Jun-11 17:26pm    
Good reply, my 5
Sergey Alexandrovich Kryukov 16-Jun-11 21:21pm    
Thank you, Espen,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900