他们的SplitButton有点braindead,国际海事组织。大多数SplitButton
s将箭头区域视为虚拟按钮,或者跳过发出Button CLick事件或者改为显示关联的下拉菜单(或两者)。大多数使用新SplitClicked事件被点击的区域时,这样你就可以根据需要使用菜单拨弄:
Protected Overrides Sub OnMouseDown(ByVal mevent As MouseEventArgs)
...
' they clicked in the arrow.split rect
If (SplitRect.Contains(mevent.Location)) Then
' notify them
RaiseEvent SplitClick(Me, New EventArgs)
' open the menu if there is one
If ShowContextMenuStrip() = False Then
skipNextClick = True ' fixup for the menu
End If
Else
' let the normal event get raised
State = PushButtonState.Pressed
MyBase.OnMouseDown(mevent)
End If
End Sub
他们没有类似的活动,但作为一种变通方法,您可以使用DropDownOpening
事件“取消”像这样按一下按钮事件(这工作,因为DropDownOpening事件始终闪光在前):
' workaround flag
Private IgnoreClickBecauseMenuIsOpening As Boolean
Private Sub RadSplitButton1_DropDownOpening(sender As Object,
e As EventArgs) Handles RadSplitButton1.DropDownOpening
IgnoreClickBecauseMenuIsOpening = True
' code to modify menu (or not)
End Sub
Private Sub RadSplitButton1_Click(sender As Object,
e As EventArgs) Handles RadSplitButton1.Click
' ignore click if menu is opening
If IgnoreClickBecauseMenuIsOpening Then
' reset flag
IgnoreClickBecauseMenuIsOpening = False
Exit Sub ' all done here
End If
' normal code to execute for a click
End Sub
你可以显示Click和ItemChanged事件的代码吗?为什么你不能注释掉RadDropDownButton点击或添加一些代码来检查特定的条件..? – MethodMan 2014-08-29 17:35:02
@DJ KRAZE对不起,但我认为这个问题不需要提供代码,因为它是不言自明的,反正我已经添加了一个代码(我不必处理ItemChanged事件,我只有1个项目),我想问的是:想象一下当你点击控件时想要启动一个MsgBox的情况,但是你也希望能够在没有启动msgbox ofcourse的情况下点击箭头时打开菜单if你打开菜单,你会选择一个项目,将执行其他事情(例如启动一个不同的msgbox)。你知道我吗?对不起我的英语不好! – ElektroStudios 2014-08-29 18:06:26
您可以检查鼠标位置与控件的边界吗? – djv 2014-08-29 22:23:18