1 Attachment(s)
[RESOLVED][2005] Align radiobuttons
Hello,
I want to align the radiobuttons in my form. But I can't use a panel, groupbox, splitcontainer of something else, because you may only select one radiobutton. Is there a simple way to align them pretty, so I don't have to gamble wat's the right place?
See my screenshot.
Greets,
Thomas
Re: [2005] Align radiobuttons
they look evenly spaced and pretty well aligned to me
Re: [2005] Align radiobuttons
Point is, I think they aren't:p
Maybe I look better (or worser;) ) but it looks unprofessional if they aren't pretty aligned, if I can't find the solution here, I let it be, but if I can, I would use it;)
Re: [2005] Align radiobuttons
The Layout Toolbar in the IDE provides you with all sorts of methods to align items. You simply need to select the items you want to line up by control clicking each one, and then you can select how to align them.
Re: [2005] Align radiobuttons
You can also set the Margin and Padding properties to the appropriate values and then let the snap-lines do the rest. If you actually gave us an idea of what you wanted then we might be able to be more specific.
Also, the fact that you only want one of the entire group selected doesn't mean you can't use containers. It just means that you'd have to write extra code to unselect options inside the other containers when one option was checked.
1 Attachment(s)
Re: [2005] Align radiobuttons
Quote:
Originally Posted by jmcilhinney
Also, the fact that you only want one of the entire group selected doesn't mean you can't use containers. It just means that you'd have to write extra code to unselect options inside the other containers when one option was checked.
That's true, but I thought there would be an easier way to align them without more code;)
Quote:
Originally Posted by jmcilhinney
If you actually gave us an idea of what you wanted then we might be able to be more specific.
I schould do it with panels and an tablelayoutpanel. (see screenshot) What would be a simple code to select only one radiobutton?
Thanks for helping!:)
Re: [2005] Align radiobuttons
vb.net Code:
Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged, _
RadioButton3.CheckedChanged, _
RadioButton2.CheckedChanged, _
RadioButton1.CheckedChanged
If DirectCast(sender, RadioButton).Checked Then
Dim ctl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order.
Do Until ctl Is Nothing
'Uncheck all radio buttons that are not the one that was just checked.
If TypeOf ctl Is RadioButton AndAlso ctl IsNot sender Then
DirectCast(ctl, RadioButton).Checked = False
End If
ctl = Me.GetNextControl(ctl, True) 'Get the next control in the tab order.
Loop
End If
End Sub
Just add as many more RadioButtons to the Handles clause as you like. I suggest doing it in the Properties window rather than typing them manually, but either will work.
Re: [2005] Align radiobuttons
Really thank you!:D
something learned today:cool: