[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need to Programatically Find Controls With ContextMenuStrips Containing "Run" MenuItem, Then Initiate Addhandler Call to SubRoutine

Posted on 2014-01-16
1
Medium Priority
?
250 Views
Last Modified: 2014-01-17
I am adding elements of each control's contextmenustrips using the code below

sender.Items.AddRange(New ToolStripItem() {ctmsview, ctmsrun, ctmsdelete})

where for example, the ctmsrun text is:

ctmsrun.Text = "Run"

If a user right clicks on a control's contextmenustrip and selects "Run", then the addhandler runs the ctmsrun routine.   Very important: once inside the ctmsrun routine, the source control's name is used to determine what to do.

Question is, what's the best way to pick off all the control's whose contextmenustrip have a "Run" menu item, and then fire the ctmsrun routine as if the user right clicked on sequential form controls (there is a defined sequence of the controls to be run, and that is known)?  

So the question is: Given many Form controls with contextmenustrips (not all controls have a contextmenustrip) what's the best way to identify those with a either "Run" as the text or ctmsrun used with the addhandler (to actually fire the subroutine).  

My guess is to just loop through all controls, identify which controls have a contextmenustrip, and then find out if there is a ctsmrun command or "Run" text in the menu item text?  The call ctmsrun somehow for that source control?

By the way, once inside the ctmsrun routine, I use the following to obtain the name of the parent control of the specific contextmenustrip that was right-clicked:  

 Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
 Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip)
 cmssourcecontrolname = cms.Name

Open in new window

   

However, I need to find out what the menu items are within the contextmenustrip.
0
Comment
Question by:lep1
[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
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 39788546
The ContextMenuStrip has the Items property, which are the menu items.  You should be able to loop through the items to get what you need.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 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