In VB 2008, is there a way to auto center buttons?

razz

Well-known member
Joined
Oct 11, 2008
Messages
67
Programming Experience
Beginner
I am creating a program using VB 2008. I need to center numerous buttons on various forms (I'm using Windows forms), is there a way to make sure the buttons are centered horizontally on the form?

Thank you for your time.
 
Highlight all the buttons and click the 'Center Horizontally' button, it's in the form view tool bar
 
Ahh, there is was :) Thank you, I've been looking for that option for 2 days :(

Windows is a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.
I love it!! Hysterical!!
 
Is there way to do the same with code?
There's no method you can call to automatically centre a control in its parent but it just takes a little bit of mathematics. Get the Width of the parent and subtract the Width of the child. Divide that by two (using integer division, i.e. \, not floating-point division, i.e. /) and assign the result to the Left property of the child.
 
Back
Top