Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding a contextmenustrip strip added in design time.

Status
Not open for further replies.

xavstone

Technical User
Apr 12, 2005
33
GB
Ok so I added a contextmenustrip to form1 in a winforms app. I have a standard class elsewhere that takes a treenode as a parameter and does things to it. One of the things I would like to do is set the context menu. The context menu was added to the form manually at design time.

I have tried things like:

Code:
public static void MethodThatAddsAContextMenu(TreeNode node)
{

node.ContextMenu = Application.OpenForms[0].Controls["myContextMenu"] as ContextMenuStrip;

And a what seems like a million subtle and not so subtle variations. My code doesn't find the control. Although it looks like the context menu isn't actually part of the forms control collection when I drill in via my watch list.

Any help appreciated. Also I did this on my iPad, looks like its formatted ok but apologies if not.

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top