J
joey.powell
Hello,
I have a windows forms application (VS2005) where I need to do the
following...
1. Startup with a main form.
2. Have the user to select a file and then bring up a second form
modally (Form1.ShowDialog()) so that the user can make custom
selections.
3. I can store the selections from the second form in many different
ways, but I have to get them back to the main form once the modal form
is closed. The selections are column header names, and right now I am
choosing to store them in a Generic List<string>.
I am doing fine so far, but now I need to figure out the best way to
get the selections back to the main form, once the user clicks
"Continue" and I call this.Close() on the second form.
I thought about creating the list and then passing a reference to the
modal form's constructor: "ref List<string> MyList". But this doesn't
work because the list is not scoped outside of the modal form's
constructor. And so I cannot interact with it when other events occur
on the form, like for example, a button click.
Another way would be create and modify the list within the second form
and then simply "return" it, but as far as I know one cannot do that
when using forms (would not be a problem with plain old functions).
There is not a return(MyList) that will work when closing a form,
right?
What would be a good way to tackle this?
I have a windows forms application (VS2005) where I need to do the
following...
1. Startup with a main form.
2. Have the user to select a file and then bring up a second form
modally (Form1.ShowDialog()) so that the user can make custom
selections.
3. I can store the selections from the second form in many different
ways, but I have to get them back to the main form once the modal form
is closed. The selections are column header names, and right now I am
choosing to store them in a Generic List<string>.
I am doing fine so far, but now I need to figure out the best way to
get the selections back to the main form, once the user clicks
"Continue" and I call this.Close() on the second form.
I thought about creating the list and then passing a reference to the
modal form's constructor: "ref List<string> MyList". But this doesn't
work because the list is not scoped outside of the modal form's
constructor. And so I cannot interact with it when other events occur
on the form, like for example, a button click.
Another way would be create and modify the list within the second form
and then simply "return" it, but as far as I know one cannot do that
when using forms (would not be a problem with plain old functions).
There is not a return(MyList) that will work when closing a form,
right?
What would be a good way to tackle this?