Elmo Watson said:
Let's say I have a child form - frmEdit - on that form a RichText
Box called txtedit
So - in VB6 days - I used to be able to refer to that particular
active form's Rich Text box - like this:
With frmMain.ActiveForm.txtedit.......
So - now - I'm using DotNet 2.0 - --
How can I do the same thing?
Reading your other question, I assume it's an MDI application.
The way you do it now was already bad practice in VB6 because not every
active Form must have a control named "txtEdit". They might have but not by
definition, as ActiveForm is of type Object and not each object has a
property txtEdit. I recommend early binding to get safer code. The solution
depends on how abstract the child form is to be. It also depends on whether
the MDI parent can contain different types of Forms or only instances of the
same Form. If the latter is the case, you can simply use
"Directcast(me.mdiparent.activemdichild, TypeOfChildForm).txtEdit". Before,
you probably will have to check that the active Form is not the Form that
does the check (because it probably does not have a txtEdit property). If
the former ist the case, you should consider deriving these Forms from the
same base form or implement an interface. Then cast to that interface or
base type to access txtEdit. You also would have to check whether the active
Form is of that type (If Typeof..is..).
In a good solution, many things must be considered to find a good design.
Armin