Board index » Visual Studio » MDI Problem

MDI Problem

Visual Studio212
This is probably a amateur problem :-)

I?ve got an MDI application. When I create my child windows from my mdi

container (frmMain) there is no problem with the MdiParent. I just set it

to Me. As following.



visa_alla.MdiParent = Me

sok_forfattare.MdiParent = Me

lagg_in_ny.MdiParent = Me



But if I want to open an instance of lagg_in_ny from sok_forfattare I can?t

set MdiParent = Me because then it will be sok_forfattare (Child) and I

want the MdiParent to be frmMain.

If I do a new frmMain as

Public frmParent As New frmMain 'MDI Parent

And set MdiParent to frmParent it wont show.

I hope I can get some help here. Its probably not so complicated but I cant

get any examples of it anywhere.



I hope anyone can help me. Thanx!



--

Message posted via www.dotnetmonster.com


-
 

Re:MDI Problem

Morgan,



Can you explain this sentence in another way



Quote
But if I want to open an instance of lagg_in_ny from sok_forfattare I

can?t

set MdiParent = Me because then it will be sok_forfattare (Child) and I

want the MdiParent to be frmMain.



Cor





-

Re:MDI Problem

"morgan petterssson via DotNetMonster.com" <forum@DotNetMonster.com>schrieb

im Newsbeitrag news:c6a0f3670a9c4cacaf93dc46c5de0042@DotNetMonster.com...

Quote
This is probably a amateur problem :-)

I?ve got an MDI application. When I create my child windows from my mdi

container (frmMain) there is no problem with the MdiParent. I just set it

to Me. As following.



visa_alla.MdiParent = Me

sok_forfattare.MdiParent = Me

lagg_in_ny.MdiParent = Me



But if I want to open an instance of lagg_in_ny from sok_forfattare I

can?t

set MdiParent = Me because then it will be sok_forfattare (Child) and I

want the MdiParent to be frmMain.

If I do a new frmMain as

Public frmParent As New frmMain 'MDI Parent

And set MdiParent to frmParent it wont show.

I hope I can get some help here. Its probably not so complicated but I

cant

get any examples of it anywhere.



What you need to do (you got that one right) is to set the value of the

MdiParent property to a reference of your frmMain Instance.

To allways be able to get a reference to your main form instance, I suggest

transforming your frmMain class into a singleton.

Then create a new Class AppStarter (or whatever you want to call it), add a

public shared sub main(), set your project startobject to that sub and do

something like



try

frmMain.GetInstance().Show()

catch ex as Exception

'Process unhandled exceptions here

end try



in your public shared sub main.





-

Re:MDI Problem

"morgan petterssson via DotNetMonster.com" <forum@DotNetMonster.com>

schrieb:

Quote
I?ve got an MDI application. When I create my child windows from my mdi

container (frmMain) there is no problem with the MdiParent. I just set it

to Me. As following.



visa_alla.MdiParent = Me

sok_forfattare.MdiParent = Me

lagg_in_ny.MdiParent = Me



But if I want to open an instance of lagg_in_ny from sok_forfattare I

can?t

set MdiParent = Me because then it will be sok_forfattare (Child) and I

want the MdiParent to be frmMain.



Inside your instance of 'SokForfattare':



\\\

Dim f As New LaggInNy()

f.MdiParent = Me.MdiParent

f.Show()

///



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:classicvb.org/petition/>">classicvb.org/petition/>



-