MouseEventArgs.LeftButton 屬性

定義

取得滑鼠左鍵的目前狀態。Gets the current state of the left mouse button.

public:
 property System::Windows::Input::MouseButtonState LeftButton { System::Windows::Input::MouseButtonState get(); };
public System.Windows.Input.MouseButtonState LeftButton { get; }
member this.LeftButton : System.Windows.Input.MouseButtonState
Public ReadOnly Property LeftButton As MouseButtonState

屬性值

滑鼠左鍵的目前狀態,可能是 PressedReleasedThe current state of the left mouse button, which is either Pressed or Released. 它沒有預設值。There is no default value.

範例

如果 LeftButton 屬性的狀態是 Pressed,下列範例會列印訊息。The following example prints a message if the state of the LeftButton property is Pressed.

if (e.LeftButton == MouseButtonState.Pressed)
{
    MessageBox.Show("The Left Mouse Button is pressed");
}
If e.LeftButton = MouseButtonState.Pressed Then
    MessageBox.Show("The Left Mouse Button is pressed")
End If

備註

@No__t 0 類別提供其他屬性和方法來判斷滑鼠的狀態。The Mouse class provides additional properties and methods for determining the state of the mouse.

適用於