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
Last edited by Mindstorms; Sep 22nd, 2007 at 05:03 AM.
Reason: Resolved
Point is, I think they aren't
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
Last edited by Mindstorms; Sep 21st, 2007 at 11:46 AM.
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.
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.
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
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?
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.