MDI Problem

  • Thread starter morgan petterssson via DotNetMonster.com
  • Start date

M

morgan petterssson via DotNetMonster.com

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!
 
Ad

Advertisements

C

Cor Ligthert

Morgan,

Can you explain this sentence in another way
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
 
D

Diana Mueller

morgan petterssson via DotNetMonster.com said:
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.
 
Ad

Advertisements

H

Herfried K. Wagner [MVP]

morgan petterssson via DotNetMonster.com said:
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()
///
 

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