0

Sir
Please help me about MenuStrip Control used.
I create a project there one parents form and two child form
MenuStripControl-1 is on parents form (main_form)
Menu Item name a) Trans. b)Report c) Setting

and
MenuStripControl-2 is on child form (purchase_Entry_Form)
Menu Item name a) File. b)Close
I want to when start the application (parents form (main_form)) then show MenuStripControl-1 menu Items only.
But
when run the child form (purchase_Entry_Form) then show MenuStripControl-2 menu Items only.
After closing child form(purchase_Entry_Form) then re show the parents form (main_form) MenuStripControl-1 menu Items only.

It is possible
please help me sir...

What I have tried:

If i Hide the MenuStripControl-1 the automatically hide MenuStripControl-2

2
Contributors
13
Replies
68
Views
3 Weeks
Discussion Span
Last Post by tinstaafl
Featured Replies
  • 2

    Assuming the parent form is designated as an `MDIContainer`. You can achieve what you want by removing the parent's menustrip from its control collection and adding the menustrip from the child form. To reverse this, handle the `FormClosed` event in the child form and remove the child form's menustrip and … Read More

  • 1

    You must be doing something different. The sample I gave you works for me and it was well tested. Try this: In the designer, double-click the menu item you want to use to close the form This will bring up a code stub in the source code. Copy the lines … Read More

  • 1

    Please remember to mark the post solved if your question is answered. Thank You Read More

2

Assuming the parent form is designated as an MDIContainer. You can achieve what you want by removing the parent's menustrip from its control collection and adding the menustrip from the child form. To reverse this, handle the FormClosed event in the child form and remove the child form's menustrip and add the parent form's menustrip. One caveat remember to access the parent as MDIParent, not Parent.

It could look something like this:

Assuming the Trans menu item is opening the child form:

Private Sub TransToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TransToolStripMenuItem.Click
    Dim ChildForm = New purchase_Entry_Form
    ChildForm.MdiParent = Me
    'By setting the `ControlBox` to false and the `Dock` to `Fill` the child form fills the parent and shows only the menu and the form.'
    ChildForm.Dock = DockStyle.Fill
    'Even though we are removing this from the Controls collection it is still present as a field of the MDIParent form and can be added
    back in when the child form closes'
    Me.Controls.Remove(MenuStrip1)
    Me.Controls.Add(ChildForm.MenuStrip1)
    ChildForm.Show()
End Sub

The child form's closing handler would look something like this:

Private Sub CloseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CloseToolStripMenuItem.Click
    Dim ParentForm As MDIParent = Me.MdiParent
    ParentForm.Controls.Remove(Me.MenuStrip1)
    ParentForm.Controls.Add(ParentForm.MenuStrip1)
    Me.Close()
End Sub

Edited by tinstaafl

0

menu not work
close menu in purchase_Entry_Form not work
please help me

Me.Close()

Edited by JModak

1

You must be doing something different. The sample I gave you works for me and it was well tested. Try this:

In the designer, double-click the menu item you want to use to close the form

This will bring up a code stub in the source code.

Copy the lines of code inside the sub routine I showed you, and Paste them inside the code stub in your source code. See if that works.

If it doesn't submit the code you've got, so that it can be debugged easier.

Edited by tinstaafl

0
 Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick

      SalesAndInventory.Controls.Remove(Me.MenuStrip11)

   End Sub   
Private Sub frmpurchase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            SalesAndInventory.Controls.Add(Me.purmenu)
            SalesAndInventory.Controls.Remove(frmpurinvrpt.MenuStrip11)

   End Sub
Private Sub frmpurchase_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

       'Dim ParentForm As SalesAndInventory = Me.MdiParent
        'ParentForm.Controls.Remove(Me.purmenu)
        'ParentForm.Controls.Add(ParentForm.MenuStrip1)

        If Application.OpenForms().OfType(Of frmpurinvrpt).Any Then
            SalesAndInventory.Controls.Remove(purmenu)
            SalesAndInventory.Controls.Add(frmpurinvrpt.MenuStrip11)
        Else
            ParentForm.Controls.Add(SalesAndInventory.MenuStrip1)
            SalesAndInventory.Controls.Remove(purmenu)
        End If

   End Sub

When i open purchase form from purchase list it open and menu work well but when i closed the purchase form from menu it is work well

after closing the purchase form----shwoing (previous open) purchase list form and its menu but menu not work

please help me sir.........

Edited by JModak

0

It appears you're using the class SalesAndInventory instead of an instance of that class. Did you mean to have the ParentForm in there instead?

0

Sir I want to when I closed the purchase entry form after edit the purchase report form show same as before I open the purchase entry form from this form.
Only menu item not work. When I open purchase entry from the list (which is filter 1st time) it is working well for test i add a close button it is work but close menu not work.
"SalesAndInventory.Controls.Remove(frmpurinvrpt.MenuStrip11)"
If I remove this line then no problem but all time show the( purchase form edit time) purchase report form menu.
Please help me

0

As I said in my post, SalesAndInventory is the name of the class. you need to use an instance of that class.

0

According to your code it's the name of the form, but to access the properties of a specific form you have to create an instance of it, like this line from your code:

Dim ParentForm As SalesAndInventory = Me.MdiParent

ParentForm becomes the name of the instance of the SalesAndInventory form.

0
Private Sub frmpurchase_FormClosing(ByVal sender As Object, ByVal e As 
        If Application.OpenForms().OfType(Of frmpurinvrpt).Any Then

            Dim ParentForm As SalesAndInventory = Me.MdiParent
            SalesAndInventory.Controls.Remove(purmenu)
            SalesAndInventory.Controls.Add(frmpurinvrpt.MenuStrip11)
        Else
            Dim ParentForm As SalesAndInventory = Me.MdiParent
            ParentForm.Controls.Add(SalesAndInventory.MenuStrip1)
            SalesAndInventory.Controls.Remove(purmenu)
        End If

End Sub

I change but result is same sir please help me

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.