|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calling UserControl from within a form in the control...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 In Form1 and Form2, define a field
Public ReadOnly myorigcontrol() as Control Then, before the form is shown; Form1.myorigcontrol = me Form1.Show Then in Form1 myvar = directcast(myorigcontrol, MyUserControl).myproperty -- Show quoteHide quoteDennis in Houston "Tom" wrote: > 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 > Or directly define it:
Public myorigcontrol() as MyUserControl Then, before the form is shown; Form1.myorigcontrol = me Form1.Show Then in Form1 myvar = myorigcontrol.myproperty myorigcontrol.myproperty = myvar -- Show quoteHide quoteDennis in Houston "Tom" wrote: > 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 >
Need to sort ListView columns that contain dates
Accessing dlls at runtime C# to VB crossover questions hide control based on SQLS2K column level permission Update Element in ArrayList Structure GetType and ApplicationClass About MessageQueue Problem Large fonts setting (120DPI) Public vs Shared Using JPG stills to make a "Video" file |
|||||||||||||||||||||||