Solved

Handling Standard Menu Strip in vb.net

Posted on 2011-03-08
3
719 Views
Last Modified: 2012-06-27
HI,
I would appreciate your help....
I have 3 win forms (1 parent mdi form and 2 child forms)
Parent form has attached standard Menu Strip...
I'm trying to use Save option in menu strip in both 2 child forms....
I tried to handle this event SaveToolStripMenuItem.Click on form 2 (which is child form) as in code below but got error as follows:
"Handles clause requires a WithEvents variable defined in the containing type or one of its base types"
Please help me in order to make this working....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, SaveToolStripMenuItem.Click

' my vb code

End Sub

Open in new window

0
Comment
Question by:alsam
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 35080386
Put your my vb code in a public function on the parent form (or in a class) and remove the handler from Button1's click event for the ToolStripMenu.

Handle the toolstripmenu click event and have both call the public function / class described above.
0
 
LVL 1

Author Comment

by:alsam
ID: 35080896
Hello nepaluz,
Thank you for your reply and given instructions...
Somehow, your proposal , in order to be implemented, required additional time and effort for me so I tried different solution that works OK with me (Code below)
Anyway thank you for your time and effort...
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        Dim currentForm As Form = Form.ActiveForm.ActiveMdiChild
        If currentForm.Text = "Form2" Then
            Form2.Button1_Click(sender, e)
            MsgBox("OK - saved")
        Else
            MsgBox("NOK")
        End If
    End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:alsam
ID: 35080928
OK
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now