Open 2 forms and close the first
-
I am currently opening a new form from my main form, then have that open another form. I can do this using the below code
List list = new List(); list.ShowDialog();
What i want to do is to be able to close the original form and the next form from the last form I open. so there for form1->open form2 from form1->open form3 from form2->close form1 and form2 from form3. any help would be great thanks.
-
I am currently opening a new form from my main form, then have that open another form. I can do this using the below code
List list = new List(); list.ShowDialog();
What i want to do is to be able to close the original form and the next form from the last form I open. so there for form1->open form2 from form1->open form3 from form2->close form1 and form2 from form3. any help would be great thanks.
Hi, You may try setting the Visible property to False on loading of the Form. E.g. On Form1_Load, Open Form2 and and set the visible property of Form1 as False. Similarly do it for the remaining Forms. I hope this would be helpful.
John Adams ComponentOne LLC. www.componentone.com
-
I am currently opening a new form from my main form, then have that open another form. I can do this using the below code
List list = new List(); list.ShowDialog();
What i want to do is to be able to close the original form and the next form from the last form I open. so there for form1->open form2 from form1->open form3 from form2->close form1 and form2 from form3. any help would be great thanks.
IMO you must have FormManager to show and close a form the FormManager contains lastOpenedForm field, and a method (ShowForm) to show a form i.e : 1. you call ShowForm to show a particular form 2. before form show check if lastOpenedForm wether null or not, if not null, call to close that form and dispose it 3. set lastOpenedForm with opened form to do this you have to know about invoking a method and there are some articles about that in CP, or be friend with Google :) hope it helps
dhaim programming is a hobby that make some money as side effect :)
-
I am currently opening a new form from my main form, then have that open another form. I can do this using the below code
List list = new List(); list.ShowDialog();
What i want to do is to be able to close the original form and the next form from the last form I open. so there for form1->open form2 from form1->open form3 from form2->close form1 and form2 from form3. any help would be great thanks.
thanks for the answers but I dont think that is what i am after. When I press a button on form3 I want to close form2 and form1. How do i do this? I try to specify there name then .close() but it doesnt work. How do i pass the name of the old forms to the new form?
-
I am currently opening a new form from my main form, then have that open another form. I can do this using the below code
List list = new List(); list.ShowDialog();
What i want to do is to be able to close the original form and the next form from the last form I open. so there for form1->open form2 from form1->open form3 from form2->close form1 and form2 from form3. any help would be great thanks.
Listen, USE USERCONTROLS Create only the main form and create as many usercontrols as you wish and load then in the main form, that will solve you problem if i get it right. You my have to type code from start. If for some reason you need forms, use child/parent forms method(child forms that load inside a parent form). Check here codeproject (i don´t recall the link) Thats me, but, you are the boss :sigh: