ToolStripSplitButton 行为覆盖
我试图了解我必须做什么才能覆盖 System.Windows.Forms
上的 ToolStripDropDown
控件的行为,如果您使用此构造函数:
var button = new ToolStripSplitButton("text","path to image", clickEventHandler)
那么 drop仅当我按住鼠标时,才会显示 down,如果我使用其他选项,
var button = new ToolStripSplitButton("text","path to image")
则当我单击时,下拉列表才会显示。
我很清楚,提供点击事件处理程序非常明确地说“嘿,当我点击时,执行这个”,但在 ToolStripSplitButton
的情况下,由于分割性质,区别有点模糊控制本身。
所以,我喜欢做的是 a) 当用户单击 ToolStripSplitButton
的按钮部分时,单击事件处理程序正常执行 b) 当我单击或在 ToolStripSplitButton
的箭头部分上按下鼠标时,下拉列表将显示
是否有任何 OOB 属性/方法可以执行此操作?
谢谢
I'm trying to understand what do I have to do to override the behavior of the ToolStripDropDown
control on System.Windows.Forms
where if you use this constructor:
var button = new ToolStripSplitButton("text","path to image", clickEventHandler)
then the drop down will only show if I keep the mouse pressed and if I use this other
var button = new ToolStripSplitButton("text","path to image")
then the drop down will show when I click.
It is clear to me that supplying a click event handler is very explicit in saying "hey, when I click, execute this" but in the case of a ToolStripSplitButton
the distinction blurs a bit because of the split nature of the control itself.
So, what I like to do is
a) When the user clicks on the button part of the ToolStripSplitButton
, the click event handler executes as normal
b) When I click OR press the mouse on the arrow part of the ToolStripSplitButton
then the drop down shows
Is there any OOB property/method to do just this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ToolStripSplitButton 有两个单击处理程序。一种称为“Click”,另一种称为“ButtonClick”。构造函数中的一个是“Click”处理程序,无论您单击控件上的哪个位置,它都会触发。 “ButtonClick”处理程序仅在您单击按钮本身(而不是箭头)时触发。
试试这个:
The ToolStripSplitButton has two click handlers. One is called "Click" and the other is called "ButtonClick". The one from the constructor is the "Click" handler and fires no matter where on the control you click. The "ButtonClick" handler only fires when you click the button itself, not the arrow.
Try this: