Override

I'm trying to figure out what I need to do to override the behavior of the control ToolStripDropDownon System.Windows.Formsif you use this constructor:

 var button = new ToolStripSplitButton("text","path to image", clickEventHandler)

then the dropdown menu will only be displayed if I hold down the mouse button and if I use this other

var button = new ToolStripSplitButton("text","path to image")

then the popup menu will be displayed when clicked.

It is clear to me that providing a click event handler very clearly says “hey, when I click, execute it”, but in case the ToolStripSplitButtondifference is slightly blurred due to the forked nature of the control itself.

So, what I like to do a) When the user clicks on a part of the button ToolStripSplitButton, the click event handler performs as usual b) When I click on the OR button, we click on the part of the arrow ToolStripSplitButton, then the drop-down list displays

Is there any OOB property / method to do this?

thank

+3
source share
1 answer

ToolStripSplitButton has two click handlers. One is called "Click" and the other is called "ButtonClick". The one that the constructor has is a "Click" handler and fires regardless of where you click the control. The ButtonClick handler runs only when the button itself is clicked, and not on the arrow.

Try the following:

var button = new ToolStripSplitButton("text","path to image");
button.ButtonClick += clickEventHandler;
+9

Source: https://habr.com/ru/post/1789733/


All Articles