ActiveForm property

E

Elmo Watson

in VB6, I'd have a MDI form (frmMain), with a midi CHild - -
then, I'd have dialogs that I run to change certain items on the rtb
(txtEdit) of the Active MDI child....

to do this, I'd say something like:
frmMain.ActiveForm.txtEdit.Seltext = "whatever"

in DotNet - - even though I have frmMain designated as an MDI form, whenever
I reference something like the above statement, wherever I'm doing it,
'frmMain' is not recognized....

Can someone set me going in the correct direction, please?
 
H

Herfried K. Wagner [MVP]

* "Elmo Watson said:
in VB6, I'd have a MDI form (frmMain), with a midi CHild - -
then, I'd have dialogs that I run to change certain items on the rtb
(txtEdit) of the Active MDI child....

to do this, I'd say something like:
frmMain.ActiveForm.txtEdit.Seltext = "whatever"

in DotNet - - even though I have frmMain designated as an MDI form, whenever
I reference something like the above statement, wherever I'm doing it,
'frmMain' is not recognized....

From within an MDI child:

\\\
DirectCast(Me.MdiParent.ActiveMdiChild, ChildForm).txtEdit.Text = "Foo"
///
 
E

Elmo Watson

What about from one of the extra dialog boxes I've created that's not an MDI
child?
(3 entities - - MDI parent/MDI child - various spawned dialog boxes which
affect the active MDI child)
 
H

Herfried K. Wagner [MVP]

* "Elmo Watson said:
What about from one of the extra dialog boxes I've created that's not an MDI
child?
(3 entities - - MDI parent/MDI child - various spawned dialog boxes which
affect the active MDI child)

Then it's the easiest solution to pass a reference to the MDI main form
to the dialogs (for example, in a property).
 
E

Elmo Watson

Creating a new property is the EASIEST way????

That, I just don't get - - why can't I just refer to the form directly???

with frmmain.activeform.txtedit.seltext - - - - that was extremely easy and
perfectly direct - - there are WAY too many times in this application where
I will enter text into the ActiveChild form, from a dialog box, to create a
property for every occasion such as this....

anyone have any other ideas?
 
H

Herfried K. Wagner [MVP]

* "Elmo Watson said:
Creating a new property is the EASIEST way????

That, I just don't get - - why can't I just refer to the form directly???

with frmmain.activeform.txtedit.seltext - - - - that was extremely easy and
perfectly direct - - there are WAY too many times in this application where
I will enter text into the ActiveChild form, from a dialog box, to create a
property for every occasion such as this....

That's because default instances don't exist any more. You can archieve
similar behavior by implementing the singleton design pattern in your
main form (have a Google search on that).
 
E

Elmo Watson

OK - I'll admit it - I'm totally mistified by this VB.Net Windows Forms
stuff - - I spent six years programming with regular VB and I thought this
wouldn't be too hard - - I feel like I landed on a different planet and I
don't understand a word anyone is saying.

I googled on the singleton design and, even though I found a lot of pages
about it - I don't understand it in the slightest.
Is there somewhere online that has some source code to show me how this is
done?

I'm spending too much time tracking down things that I don't understand to
begin with and getting more and more confused, the more you tell me -
 
H

Herfried K. Wagner [MVP]

* "Elmo Watson said:
OK - I'll admit it - I'm totally mistified by this VB.Net Windows Forms
stuff - - I spent six years programming with regular VB and I thought this
wouldn't be too hard - - I feel like I landed on a different planet and I
don't understand a word anyone is saying.

I googled on the singleton design and, even though I found a lot of pages
about it - I don't understand it in the slightest.

Does this article help to understand it?

<URL:http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top