Managing multiple forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john sutor

    #1

    Managing multiple forms

    I have a main form in a project that launches other forms. How do I ensure
    that the same form does not get launched twice without killing the orignal
    form. I other words I need a method to manage multiple forms in an app.

    Thanks

    John


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Managing multiple forms

    John,

    Have the forms register themselves in a Hashtable that is static on a
    class. When you want to create a new form or view an existing one, check
    the hashtable. If the form is in the hashtable, then use that, otherwise,
    create a new one and use that. Just make sure that if you create a new
    form, you add it to the hashtable.

    As for what you key the hashtable on, if all of your forms are different
    types, then key on the type of the form. The value is always the instance
    of the form.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "john sutor" <john_sutor@cin fin.com> wrote in message
    news:ufRlTTvdDH A.2508@tk2msftn gp13.phx.gbl...[color=blue]
    > I have a main form in a project that launches other forms. How do I[/color]
    ensure[color=blue]
    > that the same form does not get launched twice without killing the orignal
    > form. I other words I need a method to manage multiple forms in an app.
    >
    > Thanks
    >
    > John
    >
    >[/color]


    Comment

    Working...