T
Tom
Let's say I have written a VB.NET user control, with the following
components:
MyControl.sln
MyUserControl.vb (user control)
Form1 (Windows Form)
Form2 (Windows Form)
Now, lets say that within the MyUserControl I have a public function
that can be called, and that function causes the Form1 form to load in
Modal mode (ShowDialog). Now, within that form I need to be able to
access the data properties (public functions, properties, etc) from the
MyUserControl that called it (not just another instantiation, but the
actual one that loaded Form1 in the first place). The first question
is: How can I do this? I.E. How can Form1 access the data in the
MyUserControl? Yea, I could create a New constructor (or a bunch of
properties) and pass the data back and forth that way, but I really
need to be able to access the entire component (MyUserControl) that
called/created Form1. There must be a base method or something that I
can use to get back to MyUserControl but I'm having a brain fart and am
unable to figure this out.
Also, for the second question: Let's say MyUserControl also has another
public function that loads Form2 (in modal mode). On Form2, I need to
put another, new copy (visual) of MyUserControl. I'm not sure this
would work, since Form2 is already a part of MyUserControl (i.e. how
would this compile properly?)
Any advice on these two questions would be greatly appreciated. Thanks
in advance.
Tom
components:
MyControl.sln
MyUserControl.vb (user control)
Form1 (Windows Form)
Form2 (Windows Form)
Now, lets say that within the MyUserControl I have a public function
that can be called, and that function causes the Form1 form to load in
Modal mode (ShowDialog). Now, within that form I need to be able to
access the data properties (public functions, properties, etc) from the
MyUserControl that called it (not just another instantiation, but the
actual one that loaded Form1 in the first place). The first question
is: How can I do this? I.E. How can Form1 access the data in the
MyUserControl? Yea, I could create a New constructor (or a bunch of
properties) and pass the data back and forth that way, but I really
need to be able to access the entire component (MyUserControl) that
called/created Form1. There must be a base method or something that I
can use to get back to MyUserControl but I'm having a brain fart and am
unable to figure this out.
Also, for the second question: Let's say MyUserControl also has another
public function that loads Form2 (in modal mode). On Form2, I need to
put another, new copy (visual) of MyUserControl. I'm not sure this
would work, since Form2 is already a part of MyUserControl (i.e. how
would this compile properly?)
Any advice on these two questions would be greatly appreciated. Thanks
in advance.
Tom