Problem with MDI-childforms

bloukewer

Well-known member
Joined
Jul 2, 2004
Messages
88
Programming Experience
3-5
The following code exist inside an event-handler for a button:
"Dim frmAdd as New frmAdd
frmAdd.Parent = Me
frmAdd.ShowDialog()"

I get the following error message when I press the button during run-time:
"An unhandled exception of type 'System.ArgumentException' occured in system.windows.forms.dll

Additional information: Cannot add a top-level control to a control."


This is really the root of 90% of the problems I posted on this forum, a solution would REALLY HELP VERY MUCH. Thanx in advance.
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
VB.NET:
[size=2][color=#0000ff]Dim[/color][/size][size=2] frmAdd[/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] frmAdd[/size]
[size=2]frmAdd.MdiParent = [/size][size=2][color=#0000ff]Me[/color][/size]
[size=2]frmAdd.Show()

Try that[/size]
 

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
Form1 is MDIContainer , Form2 and form3 are MDIChild

If u r opening the form2 from the menu bar of the form1 then

dim f2 as new form2
f2.mdiParent = me
f2.show()

If u r opening the MdiChid from MdiChild that form3 from form2 then

dim f1 as new form1
dim f3 as new form3

f3.mdiparent = f1.ActiveForm
f3.show()
Regards..
 
Top Bottom