Solved

Handling Standard Menu Strip in vb.net

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

14 Experts available now in Live!

Get 1:1 Help Now