dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: organizing lots of controls on form

  1. #1
    Join Date
    Dec 2007
    Posts
    60

    Smile organizing lots of controls on form

    Hello:
    I have an app that has about 70 controls---sliders, ,list boxes, textboxes, radio buttons, etc. Not all of them are used at one time. Usually some sub selection of the 70. I want to set up a main page that selects the unit type with a few buttons, then shows only the controls needed for that selection. Some controls are used in a lot of situations, some for only a few setups. Probably only about 10 are needed at once.

    I was simply using the visible property & putting all of the controls on one form, but it becomes quite a layout mess. I do NOT want pop up forms, just a main form with different controls shown depending on the main selection.

    Is there an easy way to do this? Should I put the all the controls on another form(s) and somehow move them to the main form as needed??---not sure how this would be done..

    any suggestions appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: organizing lots of controls on form

    You could put certain controls into a FRAME, and turn different frames on or off. You could also dynamically draw new controls at runtime.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: organizing lots of controls on form

    And you could also concider using tabpages, which will enable you to have "more than one screen" on one form
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  4. #4
    Join Date
    Dec 2007
    Posts
    60

    Re: organizing lots of controls on form

    You could put certain controls into a FRAME, and turn different frames on or off. You could also dynamically draw new controls ....

    well---where would I put all of these frames during the design...say I want my selected controls to appear in the center of the form----I don't want to stack all of these frames in the center---I need a place to keep them until they are "loaded" into the form---any way to do that?

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: organizing lots of controls on form

    That depends on your organisaton during design time.
    When activated at runtime, only one frame ever is visible. Therefore the position of the other frames is unimportant.

    I use this technique frequently. At design time I move all unused frames to the bottom of the form, where I stack them and can still click on a corner to move it to the foreground. The frame I work on I move to the center of the form. Although I set the .Visible property to false, that doesn't mean they are invisible at design time.

    At runtime you have to move the frame to where it should show up and then set it to visible.
    Code:
      myFrame1.Move 100,100 'or wherever
      myFrame1.Visible = true
    Last edited by WoF; December 19th, 2007 at 09:38 AM.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: organizing lots of controls on form

    I've only done that with tab pages. Never really stacked frames.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

    Re: organizing lots of controls on form

    Check out the SSTab control, listed as "Microsoft Tabbed Dialog Control". Then you can have stuff grouped on different tabs. Since you can click the tabs at design-time, arranging the controls on it are pretty straight-forward.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: organizing lots of controls on form

    I thought he wanted one form?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

    Re: organizing lots of controls on form

    Quote Originally Posted by dglienna
    I thought he wanted one form?
    The SSTab control accomplishes that. Though the word "dialog" typically refers to a form, in this case it's not.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  10. #10
    Join Date
    Dec 2007
    Posts
    60

    Re: organizing lots of controls on form

    thanks for the help!!!---both the frame suggestion & the SSTtab look more viable---but I face another issue. Is it possible to have "the same" control appear on more than one tab or in more than one frame??.....say I have a slider called volume_control that must appear in 3 of 8 possible tabs or frames.

    Other parts of the program (the main screen which contains the tabs or frames) needs to work with this slider (such as reading its value)...if each volume slider is named differently, how can this easily be done? Likewise, it would be nice have to duplicate the code for each of these "duplicated" controls...any thoughts?

  11. #11
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: organizing lots of controls on form

    I had the same problem, that one control had to appear in 2 different frames. I couldn't use SSTab there because I needed individual design, so I used an array of 4 Frames of which only one is ever visible at he same time.
    To move the control, which in this case was a TextBox, from one frame to the other, I changed the .Container property.
    Code:
      TabFrame(2).Visible = True
      Set TextBox.Container = TabFrame(2)
    TextBox will now appear on TabFrame(2), but at design time sits on TabFrame(0). The relative position remains.

    Other on the SSTab. You could underlay a frame on each tab where all controls ore on and use the .Container trick like described above.
    On SSTab, the situation is like that. If you place say a TextBox at Left=480 on Tab 0 and switch to Tab 1, the SSTab control "hides" the TextBox by placing it at -75000 or something. It simply locates it far to the left.
    To bring it back, you simply can set its original .Left property at the SSTab_Click() event and it will reappear on every Tab you want.

  12. #12
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: organizing lots of controls on form

    If a control is in frame 2, then it's volume_control(2), so that each control's array # matches the frame
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

    Re: organizing lots of controls on form

    Here's an explanation of how the SSTab control works, including how to get a single control to appear on multiple tabs: http://www.codeguru.com/forum/showthread.php?t=303132
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  14. #14
    Join Date
    Feb 2008
    Posts
    6

    Re: organizing lots of controls on form

    I am looking to do the same thing...would be highly helpful if u cd send some sample files frm ur project...
    P.S requirement is urgent

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: organizing lots of controls on form

    Who?
    Attached Files Attached Files
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)