GCCal
asked on
How do I change an active control on another form from a MDI parent?
I have a MDI parent and one MDI child. The MDI parent has a tool bar. I want to push one of the toolbar buttons that will have code to click another button on the child. So far I have only been able to get it to work if the button is the active control on the child, in this case if the tab stop is 0. Writing the code in visual basic.
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, I set the code like this:
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf (frm) Is frmCVR Then
Dim mc As frmCVR = DirectCast(frm, frmCVR)
mc.Button10.PerformClick()
End If
but the button10 still does not activate. Does it look like I did it right?
Thanks,
Dim frm As Form = Me.ActiveMdiChild
If Not IsNothing(frm) AndAlso TypeOf (frm) Is frmCVR Then
Dim mc As frmCVR = DirectCast(frm, frmCVR)
mc.Button10.PerformClick()
End If
but the button10 still does not activate. Does it look like I did it right?
Thanks,
That looks good from here...
The code in Button10 isn't running?
The code in Button10 isn't running?
ASKER
Yes, the click event does not occur. However, if I click the button with the mouse the click event occurs and the code executes as it should. So what I have is the MDI form showing with the child displayed. I click the button on the MDI tool strip and no reaction. Then I click the button on the child and it excutes.
Thanks,
Thanks,
Hmmm....something must be different about your setup as it worked fine for me in a simple project.
Try creating a new project with ONLY the MdiParent form and ONE MdiChild with a simple MessageBox in the Button event.
Try creating a new project with ONLY the MdiParent form and ONE MdiChild with a simple MessageBox in the Button event.
ASKER
Yes, it worked in a new project so I have something incorrect in my application. I will work at it.
Thanks for your help Idle Mind.
GCCal
Thanks for your help Idle Mind.
GCCal
Glad you were able to make the concept work for you.
Not sure where to guide you on finding the difference in your existing application though. =\
My only thought is that somehow you don't have an "active" MdiChild and this line is returning Nothing:
Dim frm As Form = Me.ActiveMdiChild
Not sure where to guide you on finding the difference in your existing application though. =\
My only thought is that somehow you don't have an "active" MdiChild and this line is returning Nothing:
Dim frm As Form = Me.ActiveMdiChild
ASKER
First time I used your service. Great idea.
ASKER