I have a Panel
called Panel_Manage_Calculations
on a Form
called Criteria
. I have the visible property to a default of False. When I call it from my MenuStrip
called MenutStrip_Main
with this code:
Private Sub ManageCalculationsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ManageCalculationsToolStripMenuItem.Click
Criteria.Panel_Manage_Calculations.Show()
End Sub
It does not show. But if I put a button on Criteria
and use this code:
Private Sub Button4_Click(sender As Object, e As EventArgs)
Panel_Manage_Calculations.Show()
End Sub
It will show.
The only other object on Criteria
is a DataGridView
.
How can I get Panel_Manage_Calculations
to show when called from MenutStrip_Main
?
Additional Info
The only other code that might run before I click is:
Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem_Criteria.Click
For Each mdiChild As Form In Me.MdiChildren
If mdiChild.Name = "Criteria" Then
mdiChild.Activate()
Exit Sub
End If
Next
Dim frmClientConfig As New Criteria
frmClientConfig.MdiParent = Me
frmClientConfig.Show()
End Sub
Your MenuItem Click might not be hooked up correctly for instance, the Handles... clause might refer to an older name or it might simply be disabled. If the event is not firing, it is a menu thing. Try creating a new menu entry for the code.
EDIT
If the event is not firing it is likely because a) the menu item is not enabled (PERHAPS) it gets disabled in code, b) it lacks a HANDLER which seems not to be the case or C) something ELSE has that handler attached or D) the wrong form is referenced
EDIT EDIT
Ok, so we have multiple MDI forms. Based on the AddToolStripMenuItem, this is how it should look:
Private Sub ManageCalculationsToolStripMenuItem_Click(sender As Object, _
e As EventArgs) Handles ManageCalculationsToolStripMenuItem.Click
frmClientConfig.Panel_Manage_Calculations.Show()
End Sub
Criteria is the form name (Class), the instance name is frmClientConfig
. You will need to rework how this form is handled:
private frmClientConfig As Criteria ' at the top of the MDI parent
In the menu Add click:
frmClientConfig = New Criteria
frmClientConfig.MdiParent = Me
frmClientConfig.Show()
this is needed so that the menu click will know what a frmClientConfig
is. The problem was that you were issuing the Show
to the class not the instance (which seems like it should throw an error). BEWARE of where NEW
is supposed to be used!