Results 1 to 8 of 8

Thread: [RESOLVED][2005] Align radiobuttons

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Resolved [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
    Attached Images Attached Images  
    Last edited by Mindstorms; Sep 22nd, 2007 at 05:03 AM. Reason: Resolved

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2005] Align radiobuttons

    they look evenly spaced and pretty well aligned to me
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: [2005] Align radiobuttons

    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.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    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!
    Attached Images Attached Images  

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Align radiobuttons

    vb.net Code:
    1. Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, _
    2.                                        ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged, _
    3.                                                                             RadioButton3.CheckedChanged, _
    4.                                                                             RadioButton2.CheckedChanged, _
    5.                                                                             RadioButton1.CheckedChanged
    6.     If DirectCast(sender, RadioButton).Checked Then
    7.         Dim ctl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order.
    8.  
    9.         Do Until ctl Is Nothing
    10.             'Uncheck all radio buttons that are not the one that was just checked.
    11.             If TypeOf ctl Is RadioButton AndAlso ctl IsNot sender Then
    12.                 DirectCast(ctl, RadioButton).Checked = False
    13.             End If
    14.  
    15.             ctl = Me.GetNextControl(ctl, True) 'Get the next control in the tab order.
    16.         Loop
    17.     End If
    18. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Resolved Re: [2005] Align radiobuttons

    Really thank you!
    something learned today

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width