Detect Subforms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Bailo

    Detect Subforms


    I have a main form that can launch several subforms.

    Both the main form remains active when the subform is visible.

    I want to prevent the user from launching multiple copies of the subform.

    How can I do this?

    Here's my code for launching one of the subforms:


    frmMove Move = new frmMove(this,
    treeView1.Selec tedNode);

    Move.Show();
    Move.Activate() ;
    Move.TopMost=tr ue;

  • Tim Haughton

    #2
    Re: Detect Subforms

    "John Bailo" <jabailo@texeme .com> wrote in message
    news:_tydnZ2dnZ 2BmhnwnZ2dnb6in 96dnZ2dRVn-y52dnZ0@speakea sy.net...[color=blue]
    >
    > I have a main form that can launch several subforms.
    >
    > Both the main form remains active when the subform is visible.
    >
    > I want to prevent the user from launching multiple copies of the subform.[/color]

    The subform should then be a field in the parent form. The paremt form
    should only create a new subform when there isn't already one in existence.

    --
    Regards,

    Tim Haughton

    Agitek




    Comment

    • John Bailo

      #3
      Re: Detect Subforms

      Tim Haughton wrote:
      [color=blue]
      > The subform should then be a field in the parent form. The paremt form
      > should only create a new subform when there isn't already one in existence.
      >[/color]

      Well, I'm probably doing it totally wrong, but here's what I ended up doing.

      When I launch, I create a member refernce in the parent (this is not MDI):

      if(Child==null)
      frmChild Child = new frmChild(frmPar ent);


      So, at that point frmParent.Child holds the reference to the child, and
      I pass in a reference to the parent in the constructor.

      Then in the child Dispose() method I put

      frmParent.Child =null;

      So, if the child form is open, it will not launch a new form...it will
      only activate and bring the existing one to the foreground.

      Comment

      Working...