MDI form control many child form

ysseng

Member
Joined
Jan 23, 2006
Messages
6
Programming Experience
5-10
Hi everyone I'm new to vbdotnetforums.com and this is my first post in fact. I'm very much a beginner in vb.net.

i got MDI form with let say 2 child forms, each child form also got one grid and the MDI form is control the child form grid position. My problem is the user can open 2 child form together so which child form is active then the MDI is control that child grid.
 
ok i can get the ActiveMdiChild name but have no idea on passing the grid position to child form. i know normal form passing value but in this case seem cant work. pls help

thank you
 
The ActiveMdiChild property is of type Form, so you can only access members of the Form class using it directly. If you want to access members of your specific class then you need to cast it. If all your child forms are the same type then you can just cast away:
VB.NET:
Dim child As ChildForm = DirectCast(Me.ActiveMdiChild, ChildForm)
If your child forms are of different types then you'll need to handle each type seperately:
VB.NET:
If TypeOf Me.ActiveMdiChild Is ChildForm1 Then
    Dim child As ChildForm1 = DirectCast(Me.ActiveMdiChild, ChildForm1)
ElseIf TypeOf Me.ActiveMdiChild Is ChildForm2 Then
    Dim child As ChildForm2 = DirectCast(Me.ActiveMdiChild, ChildForm2)
End If
 
Back
Top