Results 1 to 13 of 13

Thread: [RESOLVED] form with dynamic and static portion

  1. #1

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Resolved [RESOLVED] form with dynamic and static portion

    hi guys! I need help. Im trying to develop a windows application and i want to have a form were there is a Static side and Dynamic side...whatever button i click on the Static side the output is always shown in the Dynamic side. Pls consider the attached screen size as example. Can any body please suggest or help me on how to do this. Thanks in advance!
    Attached Images Attached Images  

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    Is that intended to be an MDI application?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    Yap.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    Set the form's IsMdiContainer property to True. Now add a Panel to the form and set its Dock property to Left. You can now add controls, like Buttons, to the Panel like any other Panel on any other form. Each Button will presumably correspond to a different child form. Are you intending there to be only one each of the different types of child forms?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    Thanks for that JM...But, sorry i didn't understand you question, can you pls. rephrase it? Thanks!

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    You have three buttons. Presumably they each correspond to a different type of child form. Are you intending that there only ever be one instance of each type, or do you want to allow multiple instances?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    Oh..Yah, there should only be one instance. How can i prevent it from creating other instance aside from disabling the button?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    You should implement the Singleton pattern in your forms, e.g.
    C# Code:
    1. private static SingletonForm _instance;
    2.  
    3. public static SingletonForm Instance
    4. {
    5.     get
    6.     {
    7.         if (_instance == null || _instance.IsDisposed)
    8.         {
    9.             _instance = new SingletonForm();
    10.         }
    11.  
    12.         return _instance;
    13.     }
    14. }
    15.  
    16. private SingletonForm()
    17. {
    18.     InitializeComponent();
    19. }
    The only constructor is private so all interaction with the class takes place through the Instance property. That ensures that only one instance ever exists. Each time you press a button you just call the Show and Activate methods of the Instance property of the appropriate class. That ensures that the one and only instance of that class is visible and selected.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    thanks for that again JM! but i still have a problem, how will I prevent the controls, like buttons, label, etc., from my "static" panel from moving everytime i show/close the child form? Pls. see attached screenshot.
    Attached Images Attached Images  

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    The controls aren't actually moving. Their Location property is a point relative to the top, left corner of the Panel. If you maximise a child form then a control strip is created along the top of the parent form that causes the Height of the Panel to be reduced and the its Top to move downwards. The controls on the Panel remain in exactly the same Location relative to top, left corner of the Panel.

    If you don't want the controls to be anchored to the top, left corner of the Panel then you need to change their Anchor property to something other than the default {Top, Left}. Note that that will also affect their behaviour when the Height of the form changes. If that never happens then you're OK, otherwise it's something to consider.

    Another way around it would be to place a TableLayoutPanel on the Panel and set all the lower rows to static Heights and then have the top row take up whatever's left. That way if the Panel resizes only the top row of the TLP will resize.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    I'll try the TableLayoutPanel..anyway, is there any way for me to remove or prevent the control strip from appearing everytime i maximize the child form?

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: form with dynamic and static portion

    How would you access the system menu and the minimise, restore and close buttons if that control strip wasn't there?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: form with dynamic and static portion

    Oh...Sorry..im just curious..Anyway, Thank you so much for the inputs!

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