Resize - Control with Form-VBForums
Results 1 to 3 of 3

Thread: Resize - Control with Form

  1. #1

    Thread Starter
    Addicted Member sinner0636's Avatar
    Join Date
    Sep 2009
    Posts
    209

    Resize - Control with Form

    Hello i new to VB.Net how do i keep a button for say to the right side of my form when i resize the form from big to small?

    this is the code i used to use in VB6 that would do this

    Code:
    Option Explicit
    
    Private m_Gap As Single
    
    Private Sub Form_Load()
        m_Gap = ScaleWidth - (Command1.Left + Command1.Width)
    End Sub
    
    Private Sub Form_Resize()
        Command1.Left = ScaleWidth - (Command1.Width + m_Gap)
    End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,374

    Re: Resize - Control with Form

    You don't need any code at all. Select the control in the designer, open the Properties window and then edit the Anchor property appropriately. It is set to Top, Left by default but, for instance, if you want OK and Cancel buttons in the bottom, right corner then you'd change the Anchor to Bottom, Right for those two Buttons.

    You might also like to follow the CodeBank link in my signature below and check out my thread on the Anchor & Dock properties.
    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 sinner0636's Avatar
    Join Date
    Sep 2009
    Posts
    209

    Re: Resize - Control with Form

    Thank you glad its built in!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.