DataGrid.OnMouseDown(MouseEventArgs) 메서드

정의

MouseDown 이벤트를 발생시킵니다.

protected:
 override void OnMouseDown(System::Windows::Forms::MouseEventArgs ^ e);
protected override void OnMouseDown (System.Windows.Forms.MouseEventArgs e);
override this.OnMouseDown : System.Windows.Forms.MouseEventArgs -> unit
Protected Overrides Sub OnMouseDown (e As MouseEventArgs)

매개 변수

e
MouseEventArgs

MouseEventArgs 이벤트에 대한 데이터가 들어 있는 OnMouseDown(MouseEventArgs)입니다.

예제

다음 코드 예제에서는이 멤버를 사용 하는 방법을 보여 줍니다.

public ref class MyDataGrid: public DataGrid
{
protected:

   // Override the OnMouseDown event to select the whole row
   // when the user clicks anywhere on a row.
   virtual void OnMouseDown( MouseEventArgs^ e ) override
   {
      
      // Get the HitTestInfo to return the row and pass
      // that value to the IsSelected property of the DataGrid.
      DataGrid::HitTestInfo ^ hit = this->HitTest( e->X, e->Y );
      if ( hit->Row < 0 )
               return;

      if ( this->IsSelected( hit->Row ) )
               UnSelect( hit->Row );
      else
               Select(hit->Row);
   }
};
public class MyDataGrid : DataGrid 
{
    // Override the OnMouseDown event to select the whole row
    // when the user clicks anywhere on a row.
    protected override void OnMouseDown(MouseEventArgs e) 
    {
        // Get the HitTestInfo to return the row and pass
        // that value to the IsSelected property of the DataGrid.
        DataGrid.HitTestInfo hit = this.HitTest(e.X, e.Y);
        if (hit.Row < 0)
            return;
        if (this.IsSelected(hit.Row))
            UnSelect(hit.Row);
        else
            Select(hit.Row);
    }
}
Public Class MyDataGrid
    Inherits DataGrid

    ' Override the OnMouseDown event to select the whole row
    ' when the user clicks anywhere on a row.

    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    ' Get the HitTestInfo to return the row and pass
    ' that value to the IsSelected property of the DataGrid.
        Dim hit As DataGrid.HitTestInfo = Me.HitTest(e.X, e.Y)
        If hit.Row < 0 Then
            Return
        End If
        If IsSelected(hit.Row) Then
            UnSelect(hit.Row)
        Else
            [Select](hit.Row)
        End If
    End Sub
End Class

설명

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 개요를 보려면 이벤트 처리 및 발생합니다.

상속자 참고

재정의 하는 경우 OnMouseDown(MouseEventArgs) 파생된 클래스에서 호출 해야 기본 클래스의 OnMouseDown(MouseEventArgs) 메서드.

적용 대상