Closing Windows Forms
Hi Experts...
I have an issue...im confident u ppl can resolve this..
ISSUE: i have an application in which i hvnt used MDI Forms. I have around 30 buttons on the main form...on each click it opens another windows forms(so i have 30 forms now)...my prob is everytime i click multiple buttons their respective forms open...this makes the application slow n also my task-bar gets filled...When a form is opened i tried closing all the other forms by creating their objects(and using object.close() )...even this makes the performance standstill...i need solution where i can close the existing opened forms when i click any button to open a specific form...plzz help.
Thanks in advance.
naura paxPosted Sep 30, 2009, 6:24 AM
you can show only one form at a time by using
formName.ShowDialog() at button click instead of formName.Show().
Please mark answered if helpful.
naura paxPosted Sep 30, 2009, 7:11 AM
You can create a list as a variable in the form:
List
( you can also initialize it at forms load)
and add a form at each button_click.
formList.Add(formName);
and you can also provide another button from where user can close all open windows
btnClose(...)
{
for (int i=0;i
formList[i].Close();
}
you've gotta try it for understanding clearly.
naura paxPosted Sep 30, 2009, 6:55 AM
you can close forms from their respective button_click code itself,
but their can be another way if you can store a global list (collection) of window forms and store reference of each form opened in it.
you can provide another button from which you can directly close / dispose forms already opened by accessing above described collection.
I hope i'm clear.
Abhi JozPosted Sep 30, 2009, 6:47 AM