CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2007
    Posts
    11

    Post Multiple instances of same form are openning at same time. How to prevent it?

    Hi
    I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form.

    If i double click the same row or other row it opens the details of respective row again in a same form.

    For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting.

    What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time.

    Please Help me.

    Thanks in Advance.

    Ramu Medida.

  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: Multiple instances of same form are openning at same time. How to prevent it?

    1. Have a class level form variable
    2. In the double click event handler, try something like this

    Pseudocode

    Code:
    if ((formVariable == null) || (!formVariable.Created))
    {
         // create the form
    }
    
    formVariable.LoadData(.....);
    formVariable.Show();
    formVariable.BringToFront();
    I am not sure how you are opening the form to display the row data. I think you should be able to control it the place where you create the form.

  3. #3
    Join Date
    Feb 2007
    Posts
    11

    Thumbs up Re: Multiple instances of same form are openning at same time. How to prevent it?

    Thank You Very Much.

    It is working for me.

    Once Again Thank You.

    Ramu Medida.

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