How do i refer to MasterMDI form

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I have a MDI container form "frmParent". On that form there is a tabstrip
control with 2 pages. On one of those pages there is a textbox and a
button.

When the user clicks on the button a child form is opened inside the
container form "frmChild" which displays a datagrid. The WHERE clause in
the select statement which is bound to the grid comes from the textbox on
the Parent form.

How do I refer to this textbox control ?

Thanks in Advance
 
The child form should return your parent form in its .MdiParent property. You
then need to cast this returned value as your parent form, so if your MdiParent
class is named 'MyParent' and the textbox is named 'SomeTextBox', you would
access the textbox as such from the child form:

Private Function GetParentTextBox() As TextBox
Return DirectCast(Me.MdiParent, MyParent).SomeTextBox
End Function

That being said, this is poor design and it's important for you to understand
why. In this case, briefly, it is not well to have direct dependencies between
forms, especially between a child and a parent, because you lose both
reusability and robustness.

I recommend you read some books on convention and methodology. One I have read
and liked:

Application Architecture for .NET: Designing Applications and Services
Microsoft
ISBN 0-7356-1837-2

HTH,
Bob
 
Back
Top