彼らの SplitButton は少し頭がおかしいです、IMO。ほとんどSplitButton
の は矢印領域を仮想ボタンとして扱い、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