SpankySpanky
Programmer
I was hoping to get some advice for a problem I am having.
I need to call up a sequence of forms to get user input in a certain order. You click a button on a main form and it opens a dialog for the first step where you enter data, then when you click NEXT it hides and the next step appears.
I thought I would try and use good design, and create a FormController class which instantiates the forms and can show and hide the forms in a particular order and in response to custom events that are raised by pressing buttons on the forms.
It works but the problem is that if I hide one form then show the next there is an ugly flicker because there is a time when neither form is visible. I wanted to avoid this by showing the second form before hiding the first.
But I cant seem to get this to work properly because code wont resume in the FormController until the first form has been closed. I can force it to work by using Form.Show instead of Form.ShowDialog but then the forms are not modal and you can move focus back to the main form.
I tried passing the main form as a parameter to the Form.ShowDialog function so it would be parent for each dialog form. But then I cannot close form1 AFTER showing form2 (to avoid flicker) because execution wont resume in the FormController class until form1 is closed.
Can anybody suggest an elegant solution? All the forms are built so throwing them away and putting it all on one form is an unpleasant option. I previously had form1 invoking form2 invoking form3 but I thought it would be better design practice to have an external sequencer class to control the forms in an orderly fashion.
I would greatly appreciate any comments.
Thanks
I need to call up a sequence of forms to get user input in a certain order. You click a button on a main form and it opens a dialog for the first step where you enter data, then when you click NEXT it hides and the next step appears.
I thought I would try and use good design, and create a FormController class which instantiates the forms and can show and hide the forms in a particular order and in response to custom events that are raised by pressing buttons on the forms.
It works but the problem is that if I hide one form then show the next there is an ugly flicker because there is a time when neither form is visible. I wanted to avoid this by showing the second form before hiding the first.
But I cant seem to get this to work properly because code wont resume in the FormController until the first form has been closed. I can force it to work by using Form.Show instead of Form.ShowDialog but then the forms are not modal and you can move focus back to the main form.
I tried passing the main form as a parameter to the Form.ShowDialog function so it would be parent for each dialog form. But then I cannot close form1 AFTER showing form2 (to avoid flicker) because execution wont resume in the FormController class until form1 is closed.
Can anybody suggest an elegant solution? All the forms are built so throwing them away and putting it all on one form is an unpleasant option. I previously had form1 invoking form2 invoking form3 but I thought it would be better design practice to have an external sequencer class to control the forms in an orderly fashion.
I would greatly appreciate any comments.
Thanks