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:
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.
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.