Multiple opennings of same form at a time.
-
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.
-
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.
Open the form in modal mode. Form1.ShowDialog. This will keep it from opening another form until this one has been closed. Make sure you call Form1.Dispose after ShowDialog because the memory is not released when using ShowDialog as with other Show methods.
-
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.
Instead of re-creating the child form everytime you double click on the parent form, re-use a single child form, showing or hiding it as appropriate. Before you show the form, you can use a DataView on the child form to show the data you're insterested in.:)
-
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.
i would use a singleton pattern for the form roughly:
public class MyForm:Form { private static MyForm _formInstance; private MyForm() { } public static MyForm GetFormInstance() { if (_formInstance == null) _formInstance = new MyForm(); return _formInstance; } }
Hope this helps Russell -- modified at 4:15 Thursday 8th March, 2007 -
i would use a singleton pattern for the form roughly:
public class MyForm:Form { private static MyForm _formInstance; private MyForm() { } public static MyForm GetFormInstance() { if (_formInstance == null) _formInstance = new MyForm(); return _formInstance; } }
Hope this helps Russell -- modified at 4:15 Thursday 8th March, 2007