TheSwamp
Code Red => .NET => Topic started by: Draftek on June 06, 2006, 11:42:52 AM
-
VS2005 and C#:
I've written a detail viewing / insertion program that looks much like windows explorer - with the treeview to parse the directories (and company web folders) and listview for the previews.
The *Darn* users want a 'Favories' list just like Windows Explorer. No Problem I say. I create a context menu, add an item and set the ContextMenuStrip of the TreeView for the 'Add Favorite' button.
Next I need a 'Delete Favorite' context button for the Favorie pull down. That is where the problem occurs.
MenuStrips have the ContextMenuStrip property but the MenuStripMenuItem does not.
Anybody have a clue how I would add a context menu to the drop down menu item?
Should I look into Win32 calls? I have an old dll I wrote for VB pop-up menus that would probably work, I was hoping there was a c# solution.
-
I know this isn't exactly what you are looking for but it may help. This came from the help file:
private void Form1_Load(object sender, System.EventArgs e)
{
System.Windows.Forms.ContextMenu contextMenu1;
contextMenu1 = new System.Windows.Forms.ContextMenu();
System.Windows.Forms.MenuItem menuItem1;
menuItem1 = new System.Windows.Forms.MenuItem();
System.Windows.Forms.MenuItem menuItem2;
menuItem2 = new System.Windows.Forms.MenuItem();
System.Windows.Forms.MenuItem menuItem3;
menuItem3 = new System.Windows.Forms.MenuItem();
contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {menuItem1, menuItem2, menuItem3});
menuItem1.Index = 0;
menuItem1.Text = "MenuItem1";
menuItem2.Index = 1;
menuItem2.Text = "MenuItem2";
menuItem3.Index = 2;
menuItem3.Text = "MenuItem3";
textBox1.ContextMenu = contextMenu1;
}
VS2005 and C#:
I've written a detail viewing / insertion program that looks much like windows explorer - with the treeview to parse the directories (and company web folders) and listview for the previews.
The *Darn* users want a 'Favories' list just like Windows Explorer. No Problem I say. I create a context menu, add an item and set the ContextMenuStrip of the TreeView for the 'Add Favorite' button.
Next I need a 'Delete Favorite' context button for the Favorie pull down. That is where the problem occurs.
MenuStrips have the ContextMenuStrip property but the MenuStripMenuItem does not.
Anybody have a clue how I would add a context menu to the drop down menu item?
Should I look into Win32 calls? I have an old dll I wrote for VB pop-up menus that would probably work, I was hoping there was a c# solution.
-
Thanks Dave but the problem is the MenuStripMenuItem does not have the .ContextMenu property (your last line) which what I need to add a context menu to.
-
Oops sorry :oops:. Should have read your original post in more detail.
Thanks Dave but the problem is the MenuStripMenuItem does not have the .ContextMenu property (your last line) which what I need to add a context menu to.
-
No need to be sorry. I appreciate the reply.
-
Well, I have it working using a com dll I wrote in VB6.
Feels like a band-aid solution but I'll probably stick with it unless I decide to play with Win32 calls in c#.
-
Draftek,
I'm not sure if I'm reading you right: You want to display a right-click menu on an item in a pop/pulldown menu...is that it?
-
That's right Glenn,
Exactly like the Favorites Menu pull down in IE.
-
Thinking off the top of my head, could you add a context menu to the form, then trap the pop-up display event (forget what it's called but the event that fires before the pop menu is displayed) then watch for a right-click event and display your context menu accordingly?
-
That's kinda how the com menu works. I trap the mouse_down event, test for the button clicked and if the right button display my menu, then test to see if it's been clicked. Then I actually do my work in this event instead of the context menu click even.
If the item had the ContextMenu property I would merely have to set it to my menu. Sounds like I'm spoiled....
Here are what they look like, not too much of a difference to the user: