Solved

Handling Standard Menu Strip in vb.net

Posted on 2011-03-08
3
727 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

680 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