Solved

Handling Standard Menu Strip in vb.net

Posted on 2011-03-08
3
728 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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