CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    13

    Question Reuse Panel in Another Form

    BACKGROUND:
    I have a large application. The menu bar along the top makes a number of different panels visible. So there are many different "screens" (from a user point of view) on the one form.

    PROBLEM:
    The main Form is becoming a huge class. It is unweildy and doing too much. Also, I need to add more screens, so this will get worse.

    ATTEMPTED SOLUTION:
    I separated out some of the panels out and made new classes inheriting from Panel (rather than from Form). Then I could add the inherited panel to my main form. This was good for reducing the size of the main form class and separating out functionality. BUT... now I can no longer modify the panels using the visual designer. This is quite awkward when making extensive changes to the design of a panel. (a bit like the old Java days ;-D )

    QUESTION:
    Is there a way to design a panel on one form, then use it (or an instance of it) on another form?

    Many thanks,
    StonePiano

  2. #2
    Join Date
    Dec 2003
    Location
    http://map.search.ch/zuerich.en.html
    Posts
    1,074

    Re: Reuse Panel in Another Form

    Rather than subclass Panel, it is better to subclass UserControl.
    Useful? Then click on (Rate This Post) at the top of this post.

  3. #3
    Join Date
    Aug 2006
    Posts
    16

    Re: Reuse Panel in Another Form

    1 possible solution would be to use a completely seperate form with this panel instead of a panel within the calling form. You could then set the FormBorderStyle to none and just show and hide the form as needed.

  4. #4
    Join Date
    Aug 2006
    Posts
    13

    Thumbs up Re: Reuse Panel in Another Form

    Quote Originally Posted by Norfy
    Rather than subclass Panel, it is better to subclass UserControl.
    That is the answer! Thanks very much.

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