P
Peter
Hi,
I have a project with an MDI parent form (Main), which can contain any
number of MDI children (Document). The Document form contains several user
controls, designed as separate projects and referenced from the main
project. I originally had one user control doing some dataset loading on its
own, but now I need the same dataset initialized in the same way in two
different places, so I decided to put it in the MDI parent form.
Now, how do I get a reference to that form (named Main) from the control?
I've tried things like,
Idea 1)
Dim MainForm as Main
MainForm = Me.FindForm.MdiParent
but Main is not recognized as a valid type from within the control. I can
use
Dim MainForm as Form
but then it won't let me access the dataset because dsPaperColors is not a
member of System.Windows.Forms.Form. Obviously.
Idea 2)
I also tried adding a module with a property on it of type Main that the
startup form sets to Me on loading (kind of a fake global variable), but I
can't access that module from the control either.
Idea 3)
And I can't add a reference to the main project into the control, because
there is no DLL.
So how shall I go about this? I suppose I could just pass the main MDI
parent form as an argument to the constructor of the control, but that seems
kinda hacky... there should be an easier, IntelliSense-friendly way to do
it.
I have a project with an MDI parent form (Main), which can contain any
number of MDI children (Document). The Document form contains several user
controls, designed as separate projects and referenced from the main
project. I originally had one user control doing some dataset loading on its
own, but now I need the same dataset initialized in the same way in two
different places, so I decided to put it in the MDI parent form.
Now, how do I get a reference to that form (named Main) from the control?
I've tried things like,
Idea 1)
Dim MainForm as Main
MainForm = Me.FindForm.MdiParent
but Main is not recognized as a valid type from within the control. I can
use
Dim MainForm as Form
but then it won't let me access the dataset because dsPaperColors is not a
member of System.Windows.Forms.Form. Obviously.
Idea 2)
I also tried adding a module with a property on it of type Main that the
startup form sets to Me on loading (kind of a fake global variable), but I
can't access that module from the control either.
Idea 3)
And I can't add a reference to the main project into the control, because
there is no DLL.
So how shall I go about this? I suppose I could just pass the main MDI
parent form as an argument to the constructor of the control, but that seems
kinda hacky... there should be an easier, IntelliSense-friendly way to do
it.