S
Steve_Black
I posted a similar message earlier but we've geared away from the
original topic somewhat so I thought I'd post again in hopes of getting
input from others.
I am creating a MenuStrip dynamically. For each ToolStripMenuItem, I'm
adding an event handler so that the same routine gets called regardless
of which menu item was clicked. All of this works great - my menu is
being loaded properly and my routine gets called properly.
Within the Tag property of each ToolStripMenuItem I store the name of a
form that I want opened as an mdi child of my main form. I couldn't
get this to work properly, so for testing purposes I've reduced my
problem to the following scenario (which really has nothing to do with
the Tag property or the fact that my form names are stored in
variables):
Behind my main form I created the following routine:
Private Sub LoadForm()
Dim frm As New frmTest
With frm
.MdiParent = Me
.Left = 0
.Top = 0
.Show()
End With
End Sub
I also added a button to my form and in the click event of the button,
I call the above routine.
In my routine that gets called when a menu item is clicked, I call the
same LoadForm routine.
If I click my button, frmTest loads as an mdi child as it should.
If I click a menu item, my form does not get loaded (and yes, I've
confirmed that the routine is getting called).
Incidentally, if I comment out the line that says '.MdiParent = Me', my
form will open as a normal Windows form. However, as soon as I
uncomment out that line, my form will not load.
I'm puzzled as to why such a simple thing would work when I click a
button but not when I click a menu item.
As an aside, I tried loading a menu with static menu items (instead of
loading it dynamically), and everything worked fine - my mdi child form
loaded properly.
Any help would be greatly appreciated.
Thanks,
Steve
original topic somewhat so I thought I'd post again in hopes of getting
input from others.
I am creating a MenuStrip dynamically. For each ToolStripMenuItem, I'm
adding an event handler so that the same routine gets called regardless
of which menu item was clicked. All of this works great - my menu is
being loaded properly and my routine gets called properly.
Within the Tag property of each ToolStripMenuItem I store the name of a
form that I want opened as an mdi child of my main form. I couldn't
get this to work properly, so for testing purposes I've reduced my
problem to the following scenario (which really has nothing to do with
the Tag property or the fact that my form names are stored in
variables):
Behind my main form I created the following routine:
Private Sub LoadForm()
Dim frm As New frmTest
With frm
.MdiParent = Me
.Left = 0
.Top = 0
.Show()
End With
End Sub
I also added a button to my form and in the click event of the button,
I call the above routine.
In my routine that gets called when a menu item is clicked, I call the
same LoadForm routine.
If I click my button, frmTest loads as an mdi child as it should.
If I click a menu item, my form does not get loaded (and yes, I've
confirmed that the routine is getting called).
Incidentally, if I comment out the line that says '.MdiParent = Me', my
form will open as a normal Windows form. However, as soon as I
uncomment out that line, my form will not load.
I'm puzzled as to why such a simple thing would work when I click a
button but not when I click a menu item.
As an aside, I tried loading a menu with static menu items (instead of
loading it dynamically), and everything worked fine - my mdi child form
loaded properly.
Any help would be greatly appreciated.
Thanks,
Steve