Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Handling Standard Menu Strip in vb.net

Posted on 2011-03-08
3
Medium Priority
?
739 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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