Results 1 to 5 of 5

Thread: [2005] [RESOLVED] Express Control Command Buttons

  1. #1

    Thread Starter
    Lively Member Christineeve's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    78

    [2005] [RESOLVED] Express Control Command Buttons

    Hi,
    I have eleven command buttons and a label that I'd like to center in the forum.

    My form detects the monitor size, and it will maximize the GUI to the size of the monitor. But the buttons stay where they are.

    I knew how to control buttons in a control array in VB 6.0 but despite weeks of searching and buying a book on VB, I cannot figure out how to control these buttons and label as a group.

    I tried to put them in a frame and lost references. I wrecked my project so bad, I had to go back to an older version of my ap and start over. I'm not feeling confident about trying to put these buttons back in a group box, but I will try again under expert guidence. If that's the way to do it.

    This is what I have and I'd like a few hints in figuring out how to get these buttons and label centered on my main form, regardless of the size of the monitor.

    VB Code:
    1. Sub centerme()
    2.         'Center the form according to the size of the monitor.
    3.         Me.Size = New Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    4.     End Sub


    VB Code:
    1. Sub SetControlArray(ByVal thisForm As System.Windows.Forms.Form)
    2.         'This procedure creates the array of buttons necessary for the
    3.         'the mission to launch.
    4.         'I created this array to attempt to control all the buttons as a unit.
    5.  
    6.         Dim i As Integer
    7.         Dim ctl As Control()  
    8.  
    9.         ButtonArray(0) = cmdMissionPrologue
    10.         ButtonArray(1) = cmdMissionOne
    11.         ButtonArray(2) = cmdMissionTwo
    12.         ButtonArray(3) = cmdMissionThree
    13.         ButtonArray(4) = cmdMissionFour
    14.         ButtonArray(5) = cmdMissionFive
    15.         ButtonArray(6) = cmdMissionSix
    16.         ButtonArray(7) = cmdMissionSeven
    17.         ButtonArray(8) = cmdMissionEight
    18.         ButtonArray(9) = cmdMissionNine
    19.         ButtonArray(10) = cmdMissionTen
    20.        
    21.            For Each thisControl As System.Windows.Forms.Control In thisForm.Controls
    22.             'here, I should be able to tell my command buttons to center on
    23.             'the form
    24.           Next
    25.  
    26.  End Sub

    If you can point me in the right direction to research this, I'd appreciate it. Thanks for your help!
    Last edited by Christineeve; Apr 22nd, 2006 at 11:06 AM. Reason: RESOLVED
    Christine Lee
    VB '05 Newbie
    Anything but ordinary
    ------------------------------
    Newbie: VB '05 Express Videos:
    http://msdn.microsoft.com/vstudio/ex...g/default.aspx
    My Space! My family!
    http://www.myspace.com/christineeve

  2. #2
    Hyperactive Member nothingofvalue's Avatar
    Join Date
    Jul 2005
    Location
    Arizona
    Posts
    489

    Re: [2005] Express Control Command Buttons

    It sounds like all you are wanting to do is ensure that your contols stay in their positions relative to the size of the form. This is contolled during design time by setting each controls ANCHOR property. By default they are each set to top and left or bottom and left. Depending upon the control and the behavior desired you will just need to change the property in the properties window.
    "Imagination is more important than knowledge..."

    Albert Einstein
    -----------------------------------------------
    If my reply helped you then you really were lost, but I still took the time to help, please rate it anyway

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,487

    Re: [2005] Express Control Command Buttons

    The Anchor property is not a panacea when it comes to layout on resizing forms. It's really only useful in certain situations. You may want to take a look at the FlowLayoutPanel or, more likely in your situation the TableLayoutPanel. They behave much like HTML pages when the browser resizes. Below is a screenshot of the TableLayoutPanel in action. Note that you can only place one control in each cell, but that control can be a container, like a Panel, that can then contain other controls. You would normally use the TableLayoutPanel in conjunction with Dock and/or Anchor properties. The TableLayoutPanel in the screenshot has its Dock property set to Full.
    Attached Images Attached Images  

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,487

    Re: [2005] Express Control Command Buttons

    Also, the Express video series (see my signature for a link) has episodes devoted to each of the layout panels.

  5. #5

    Thread Starter
    Lively Member Christineeve's Avatar
    Join Date
    Mar 2006
    Location
    Germany
    Posts
    78

    Re: [2005] Express Control Command Buttons

    I will give this a whirl. For fun I will mark it resolved. Thanks again.
    Christine Lee
    VB '05 Newbie
    Anything but ordinary
    ------------------------------
    Newbie: VB '05 Express Videos:
    http://msdn.microsoft.com/vstudio/ex...g/default.aspx
    My Space! My family!
    http://www.myspace.com/christineeve

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