English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello, just asking for help on how to make a command button remain in the center of a form in Visual Basic even if you resize the form. How do you make it remain in the center? I've tried so many codes already....Please help! Thanks!

2007-07-15 02:29:40 · 2 answers · asked by Mark B 2 in Computers & Internet Programming & Design

2 answers

Each form and control have properties for Height and Width which will give you size information. To find the center of a form you determine the halfway point of the Height and width.

Each control also has a TOP and LEFT property which is used to position the upper left corner of the control on the form. To move this point to the center of the form you would set these properties to the half way point determined above.

To perfectly center the control you will have to atke into account the height and width of the control and subtract half of these values from the forms center point.

This computation and setting of properties can be placed into a subroutine you can name "CenterButton"

You will then call the CenterButton proceedure when the form is first created and every time the form is resized.

There are some pit falls you will have to plan on and deal with.
1.) Limit the minimum size the form may be dragged to
2.) Not call the CenterButton proceedure when the form is minimized

2007-07-15 03:47:09 · answer #1 · answered by MarkG 7 · 0 0

Mark this might help

http://www.google.co.uk/search?hl=en&q=Make+A+Command+Button+Remain+in+the+Center+of+A+Form+in+VIsual+Basic+&btnG=Search&meta=

2007-07-15 09:35:14 · answer #2 · answered by Joe_Young 6 · 0 1

fedest.com, questions and answers