-
May 5th, 2005, 10:58 AM
#1
Thread Starter
Frenzied Member
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:
Me.centerControl.Location = New Point((Me.Width / 2) - (Me.centerControl.Width / 2), (Me.Height / 2) - (Me.centerControl.Height / 2))
Me.leftControl.Width = Me.centerControl.Location.X - 2
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
-
May 8th, 2005, 06:22 AM
#2
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.
-
May 8th, 2005, 05:14 PM
#3
Thread Starter
Frenzied Member
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
-
May 12th, 2005, 06:58 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|