PDA

Click to See Complete Forum and Search --> : Calling classess from MDI Forms


SALIH
Mar 6th, 2003, 03:39 AM
Dear All
I have got 6 different classes (forms) in my project and each has got different Mscommlib Program.
This forms are accessible from the MDI Form (by buttons)
I like to activate this classes forms from the MDI Form.
with out opening the classes (forms)
(I used private data types for local classess. should I change them to public???)
Because they are always logging the data to the SQLDB
How can I call them From the MDI Form
and also if any message arise from the forms which is currently not opened
should be able to display on the MDI Form or on the recently active form.

any related examples and clues will be appreciated.
Many Thanks in advance
salih

Grimfort
Mar 6th, 2003, 04:15 AM
You have to remember that in .Net just about everything is an object, and to pass messages to them, you have to have a reference to them. If you for instance put this code under a button:


Private Sub Button()

dim frmNew as New Form1

frmNew.Show

End Sub


then the refence is inside the procedure, when you want to access the form later on, you cant as your reference has just gone out of scope ! As you can see your form is still displayed, which means that there has to be a reference somewhere, in this case (For an MDI form) it would be under Me.OwnedForms.

Basically, keep a reference to each form you want to access, its much easier, declare them as private to your main form.


Private frmForm1 as Form1
Private frmForm2 as Form2

Then when you want to make a new form, just do this

frmForm1 = New Form1


Then later on, use that reference so you can call it:

frmForm1.Text = "My new title"
frmForm1.Show
etc