HighTechTalks DotNet Forums  

multiple childs in MDIParent

VB.net microsoft.public.dotnet.languages.vb


Discuss multiple childs in MDIParent in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Paul Mars
 
Posts: n/a

Default multiple childs in MDIParent - 05-01-2004 , 07:33 PM






FormParent load opens FormChildA.
FormChildA btn click opens FormChildB.
(FormChildA and FormChildB are both children of FormParent)
(FormChildA and FormChildB are different forms)

Problem: FormChildA btn click can only open one instance for FormChildB. I
need multiple instances of FormChildB.

Any suggestions or ideas please.

tx,
Paul



Reply With Quote
  #2  
Old   
Rob Teixeira [MVP]
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-01-2004 , 09:29 PM






in FormChildA button click:

Dim newFormB as New FormChildB
newFormB.Show

-Rob Teixeira [MVP]

"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote

Quote:
FormParent load opens FormChildA.
FormChildA btn click opens FormChildB.
(FormChildA and FormChildB are both children of FormParent)
(FormChildA and FormChildB are different forms)

Problem: FormChildA btn click can only open one instance for FormChildB. I
need multiple instances of FormChildB.

Any suggestions or ideas please.

tx,
Paul





Reply With Quote
  #3  
Old   
Paul Mars
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-01-2004 , 09:45 PM



your newFormB would then not be a child. It needs to be child of FormParent.

The original FormChildB and FormChildA are both declared in FormParent.
FormChildB is module level Public Shared

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote

Quote:
in FormChildA button click:

Dim newFormB as New FormChildB
newFormB.Show

-Rob Teixeira [MVP]

"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote in message
news:OFpEX09LEHA.3012 (AT) tk2msftngp13 (DOT) phx.gbl...
FormParent load opens FormChildA.
FormChildA btn click opens FormChildB.
(FormChildA and FormChildB are both children of FormParent)
(FormChildA and FormChildB are different forms)

Problem: FormChildA btn click can only open one instance for FormChildB.
I
need multiple instances of FormChildB.

Any suggestions or ideas please.

tx,
Paul







Reply With Quote
  #4  
Old   
Rob Teixeira [MVP]
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-01-2004 , 10:46 PM



Dim newFormB as New FormChildB
newFormB.MDIParent = FormParent
newFormB.Show

-Rob Teixeira [MVP]

"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote

Quote:
your newFormB would then not be a child. It needs to be child of
FormParent.

The original FormChildB and FormChildA are both declared in FormParent.
FormChildB is module level Public Shared




Reply With Quote
  #5  
Old   
Paul Mars
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 09:11 AM



This will not work Rob. If I put this in ChildB, it would not recognize
"FormParent". Also, generally why make a second dim for multiple instances?
My code:
Public Class FormParent

Inherits System.Windows.Forms.Form

Windows Form Designer generated code

Public Shared childBInst As New childB

Private Sub OpenChildA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenChildA.Click

Dim childAInst As New childA

With childAInst

..MdiParent = Me

..Show()

..Text = "1st"

End With

childBInst.MdiParent = Me

End Sub

End Class

-------------------------------------

Public Class childA

Inherits System.Windows.Forms.Form

Windows Form Designer generated code

Private Sub OpenChildB_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenChildB.Click

with FormParent.childBInst

..Show()

..Text = "2nd"

End With

End Sub

End Class



"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote

Quote:
Dim newFormB as New FormChildB
newFormB.MDIParent = FormParent
newFormB.Show

-Rob Teixeira [MVP]

"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote in message
news:O3nhN%23%23LEHA.1032 (AT) tk2msftngp13 (DOT) phx.gbl...
your newFormB would then not be a child. It needs to be child of
FormParent.

The original FormChildB and FormChildA are both declared in FormParent.
FormChildB is module level Public Shared






Reply With Quote
  #6  
Old   
Armin Zingler
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 09:37 AM



"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> schrieb
Quote:
This will not work Rob. If I put this in ChildB, it would not
recognize "FormParent". Also, generally why make a second dim for
multiple instances? My code:
Of course it doesn't recognize FormParent, but I think it's still the same
MDIParent, so you can also use the same MDIParent:

Dim newFormB as New FormChildB
newFormB.MDIParent = Me.MDIParent
newFormB.Show



--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



Reply With Quote
  #7  
Old   
Rob Teixeira [MVP]
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 10:19 AM




"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote

Quote:
This will not work Rob. If I put this in ChildB, it would not recognize
"FormParent".
Alright, I'll have to be a little more explicit. I should have typed this in
the first place :-)
The issue is that the MdiParent property needs a reference to the MDI form
class, not the name of the MDI form class. But since formA is already an MDI
child, this is easy.

In the childA button click event handler, type:

Dim formB as New childB
formB.MdiParent = Me.MdiParent
formB.Show

Quote:
Also, generally why make a second dim for multiple instances?
You don't need a second Dim, but your property is a Shared instance.
You could use:

FormParent.childBInst = New childB
With FormParent.childBInst
.MdiParent = Me.MdiParent
.Show
End With

But the Shared reference will only point to the newest childB instance
anyway.

-Rob Teixeira [MVP]


Quote:
My code:
Public Class FormParent

Inherits System.Windows.Forms.Form

Windows Form Designer generated code

Public Shared childBInst As New childB

Private Sub OpenChildA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenChildA.Click

Dim childAInst As New childA

With childAInst

.MdiParent = Me

.Show()

.Text = "1st"

End With

childBInst.MdiParent = Me

End Sub

End Class

-------------------------------------

Public Class childA

Inherits System.Windows.Forms.Form

Windows Form Designer generated code

Private Sub OpenChildB_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenChildB.Click

with FormParent.childBInst

.Show()

.Text = "2nd"

End With

End Sub

End Class



"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:ONUfMg$LEHA.3012 (AT) tk2msftngp13 (DOT) phx.gbl...
Dim newFormB as New FormChildB
newFormB.MDIParent = FormParent
newFormB.Show

-Rob Teixeira [MVP]

"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> wrote in message
news:O3nhN%23%23LEHA.1032 (AT) tk2msftngp13 (DOT) phx.gbl...
your newFormB would then not be a child. It needs to be child of
FormParent.

The original FormChildB and FormChildA are both declared in
FormParent.
FormChildB is module level Public Shared








Reply With Quote
  #8  
Old   
Cor Ligthert
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 10:46 AM



Hi Paul,

In this thread is everytime a new instance of an form created in the
samples.

I showed you withouth doing that. The way I did it was create them shared in
the mdi container.

Keep in mind that what is showed in this thread is a totally different
approache from what I showed. (I showed it you only because you did ask to
make it able to open form3 in form2 by the way, wherein I showed you that
you can show and hide it everywhere)

When you do not take the approach I took, there is in my opinon also no need
to create the form shared in my opinion, however keep than in mind that the
information on the form will also everytime in default new state.

Cor



Reply With Quote
  #9  
Old   
Paul Mars
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 11:37 AM



I tried and it does not work. Want see see my 200k app?

p

"Armin Zingler" <az.nospam (AT) freenet (DOT) de> wrote

Quote:
"Paul Mars" <paulmarsREMOVE (AT) netzero (DOT) com> schrieb
This will not work Rob. If I put this in ChildB, it would not
recognize "FormParent". Also, generally why make a second dim for
multiple instances? My code:

Of course it doesn't recognize FormParent, but I think it's still the same
MDIParent, so you can also use the same MDIParent:

Dim newFormB as New FormChildB
newFormB.MDIParent = Me.MDIParent
newFormB.Show



--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html




Reply With Quote
  #10  
Old   
Paul Mars
 
Posts: n/a

Default Re: multiple childs in MDIParent - 05-02-2004 , 11:44 AM



I tried your method before and it did not work for me. May be my fault, I
will try it again.

I will also try Rob's last post.

Except right now my wife said "Beach Time". It is nice out. Thanks for all
your help so far, see ya later this afternoon(hopefully).

Paul

"Cor Ligthert" <notfirstname (AT) planet (DOT) nl> wrote

Quote:
Hi Paul,

In this thread is everytime a new instance of an form created in the
samples.

I showed you withouth doing that. The way I did it was create them shared
in
the mdi container.

Keep in mind that what is showed in this thread is a totally different
approache from what I showed. (I showed it you only because you did ask to
make it able to open form3 in form2 by the way, wherein I showed you that
you can show and hide it everywhere)

When you do not take the approach I took, there is in my opinon also no
need
to create the form shared in my opinion, however keep than in mind that
the
information on the form will also everytime in default new state.

Cor





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.