[quote="Fare":9a20b]This doesn't exactly fall into the category of "Comments, suggestions, and bug-fixes", but more or less a question. I like the feature of a splitbutton, but I am unable to get it to do anything besides throw down a menu and make as selection (and click it). How do you set up the event handler so that when you click the button (after the selection is made) to read the selection (from the context menu). I've been really frustrated trying to figure this out and I figure your a good enough person to ask, since you've implemented it and everything.
Your question, if I understand it correctly, is how to get event handlers for the menu items. If this is your question, you can do it two ways.
1. The easy way
In Visual Studio designer, click the menu you want to add the even to, then double click one of the sub-items. Visual Studio will automatically generate the click method for that sub-item.
2. The more flexible way
You can also handle more than one of the sub-items in the same method:
- Event handler for the submenu to handle multiple clicks.
- multimnuclick.png (3.82 KiB) Viewed 22413 times
After you double click that event handler from the properties window, you can use this code to figure out which item was selected (where menuUpload is the name of my sub-menu):
private void menuUpload_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
int clickedIndex = menuUpload.Items.IndexOf(e.ClickedItem);
//clickedIndex is the index of the click menu Item
//now use clickedIndex to determine you action
I hope I've answered your question.