QueryContinueDragEventArgs.KeyState 속성

정의

Shift, Ctrl 및 Alt 키의 현재 상태를 가져옵니다.

public:
 property int KeyState { int get(); };
public int KeyState { get; }
member this.KeyState : int
Public ReadOnly Property KeyState As Integer

속성 값

Shift, Ctrl 및 Alt 키의 현재 상태입니다.

예제

다음 코드 예제에서는이 멤버를 사용 하는 방법을 보여 줍니다. 예제에서는 이벤트 처리기에서 보고서를 Control.QueryContinueDrag 이벤트입니다. 이 보고서를 통해 이벤트 발생 하 고 도움이 될 수 있습니다 디버깅 하는 경우를 학습할 수 있습니다. 자주 발생 하는 이벤트 또는 여러 이벤트를 보고 하려면 바꾸는 것이 좋습니다 MessageBox.Show 사용 하 여 Console.WriteLine 줄에 메시지를 추가 또는 TextBox합니다.

예제 코드를 실행 하려면에서 상속 되는 형식의 인스턴스를 포함 하는 프로젝트에 붙여넣습니다 Control와 같은 Button 또는 ComboBox합니다. 다음 인스턴스 이름을 Control1 이벤트 처리기를 연결 된 확인 된 Control.QueryContinueDrag 이벤트입니다.

private void Control1_QueryContinueDrag(Object sender, QueryContinueDragEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "KeyState", e.KeyState );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "EscapePressed", e.EscapePressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "QueryContinueDrag Event" );
}
Private Sub Control1_QueryContinueDrag(sender as Object, e as QueryContinueDragEventArgs) _ 
     Handles Control1.QueryContinueDrag

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyState", e.KeyState)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "EscapePressed", e.EscapePressed)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Action", e.Action)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"QueryContinueDrag Event")

End Sub

설명

속성에 KeyState 설정된 비트는 작업 중에 누른 키 또는 마우스 단추를 식별합니다. 예를 들어 마우스 왼쪽 단추를 누르면 속성의 첫 번째 비트가 KeyState 설정됩니다. 비트 AND 연산자를 사용하여 지정된 키 상태를 테스트할 수 있습니다.

다음 표에서는 지정된 이벤트에 대해 설정된 비트를 나열합니다.

bit
1 마우스 왼쪽 단추입니다.
2 마우스 오른쪽 단추입니다.
4 Shift 키입니다.
8 CTL 키입니다.
16 마우스 가운데 단추입니다.
32 Alt 키입니다.

기본적으로 이벤트는 왼쪽, QueryContinueDrag 가운데 또는 오른쪽 마우스 단추를 눌렀다는 것을 나타내는 경우 KeyState 로 설정합니다 ActionDragAction.Drop.

적용 대상

추가 정보