Results 1 to 4 of 4

Thread: keep 3 controls centered on a form

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    keep 3 controls centered on a form

    If you have 3 controls (and the code can be altered to accomodate more), you can use the code below to center one control, and size the two on the sides to fill the gaps:
    VB Code:
    1. Me.centerControl.Location = New Point((Me.Width / 2) - (Me.centerControl.Width / 2), (Me.Height / 2) - (Me.centerControl.Height / 2))
    2. Me.leftControl.Width = Me.centerControl.Location.X - 2
    3. Me.rightControl.Width = Me.leftControl.Width - 2

    i subtracted 2 from the widths to give some 'breathing room'
    pretty simple..Thanks to RobDog for the first line of code

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: keep 3 controls centered on a form

    Can't you do all this with the Anchor property?
    I don't live here any more.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: keep 3 controls centered on a form

    probably so but using the code above, it resizes in real-time when a user resizes the container control.

    just tossing in my little bit of knowledge i gained

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: keep 3 controls centered on a form

    Fair enough, but Anchor is real time too.

    I don't live here any more.

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