C# Ignore DropDownButtonPressed for ToolStripButton Converted to ToolStripSplitButton

When you convert a ToolStripButton to a ToolStripSplitButton, the underlying event code is not automatically converted. So you may notice clicking the split button’s down-down arrow also triggers the button’s Click event.

You can either move the Click event code to the new ButtonClick event (preferred), or adjust the Click event to ignore the drop-down arrow.

if (((ToolStripSplitButton)sender).ButtonPressed)
{
	// Do something
}

If you decide to use the method above, you can also catch the drop-down click event with…

if (((ToolStripSplitButton)sender).DropDownButtonPressed)
{
	// Do something
}

Note: Changing ToolStripButton to ToolStripSplitButton provides new event listeners. The code above was used briefly during testing and is only being posted to help anyone encountering the same issue.

Leave a Reply

Your email address will not be published. Required fields are marked *