CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2004
    Posts
    32

    Smile centering controls in form

    hello guys

    i have a problem

    i have created one of my programs which is consisting of form , small form which has controls and buttons now if i maximuzie the form the buttons and contros will appear i the lift side of the form, my quation is how can i make the controls and buttons appear in the middle of the form when i maximize the form ??

    thanks

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: centering controls in form

    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Nov 2004
    Posts
    32

    Re: centering controls in form

    thank you wizbang this exacally what i want but..

    what i need some thing more i need my program to do the same but with out resizing the buttons, the buttons should stay the same but put them in the center

    thanks again

  4. #4
    Join Date
    Dec 2001
    Posts
    6,332

    Re: centering controls in form

    To center a control horizontally, you can do this:
    Code:
    Private Sub Form_Resize()
    Command1.Left = Me.Width \ 2 - Command1.Width \ 2
    End Sub
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    Nov 2004
    Posts
    32

    Re: centering controls in form

    wizbang

    i have problem with the last code

    the program that i have created is a calculator so when i write that code all of the buttons align in the same position, so what is the solution for that

    thanks

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: centering controls in form

    An easy way would be to put the buttons in a frame, and just move that. You can set the BorderStyle to None if you don't want it to be seen.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  7. #7
    Join Date
    Nov 2004
    Posts
    32

    Re: centering controls in form

    wizbang it is a good idea

    but how can i move the buttons along with the frame , or how can i attach the buttons to the frame so they will move along

    thanks

  8. #8
    Join Date
    Dec 2001
    Posts
    6,332

    Re: centering controls in form

    You can select all the buttons that you want to put in the frame, and select Cut from the Edit menu. Then select the frame, and Paste them in.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  9. #9
    Join Date
    Nov 2004
    Posts
    32

    Re: centering controls in form

    wizbang thank you very much for helping

    it worked fine


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

Featured