Results 1 to 3 of 3

Thread: [RESOLVED] [2008] Maintain Control Location

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    148

    Resolved [RESOLVED] [2008] Maintain Control Location

    Hi. Is there any way I can make a control on a form stay in the same position from all sides when I resize the window? For example, if I have a radiobutton in the middle of the form and then I maximize the form. The radio button will no longer be in the middle.

    Anchoring doesn't seem to work for location, as I think it only alters a control's size. So is there any way I can make my controls stay in the same position relative to the size of the window?

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

    Re: [2008] Maintain Control Location

    What you're asking for is possible but can be tricky. The first possibility is handling the SizeChanged event of your form and manually calculating the correct position for the control. It's just a bit of simple maths.

    The second option is to use a TableLayoutPanel. You can add a TLP to the form and dock it. You then add three rows and three columns. The first and last of each are set to 50% and the middle of each is set to autosize. You stick the control in the centre cell and it will stay centred in the form as it resizes.

    The problem comes if you have other controls on the form.
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    148

    Re: [2008] Maintain Control Location

    Alright thanks, I got it to work

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