DataGridView.HitTestInfo.Type 속성

정의

현재 DataGridViewHitTestType에서 설명하는 좌표가 속한 DataGridView 부분을 나타내는 DataGridView.HitTestInfo을 가져옵니다.

public:
 property System::Windows::Forms::DataGridViewHitTestType Type { System::Windows::Forms::DataGridViewHitTestType get(); };
public System.Windows.Forms.DataGridViewHitTestType Type { get; }
member this.Type : System.Windows.Forms.DataGridViewHitTestType
Public ReadOnly Property Type As DataGridViewHitTestType

속성 값

DataGridViewHitTestType

현재 DataGridViewHitTestType에서 설명하는 좌표에 있는 컨트롤 부분을 나타내는 DataGridView.HitTestInfo 값입니다.

예제

다음 코드 예제에서는이 속성의 사용을 보여 줍니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 DataGridView.Columns 속성 참조 항목입니다.

private DataGridViewCell clickedCell;

private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
// If the user right-clicks a cell, store it for use by the shortcut menu.
    if (e.Button == MouseButtons.Right)
    {
        DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);
        if (hit.Type == DataGridViewHitTestType.Cell)
        {
            clickedCell =
                dataGridView1.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
        }
    }
}
Private clickedCell As DataGridViewCell

Private Sub dataGridView1_MouseDown(ByVal sender As Object, _
    ByVal e As MouseEventArgs) Handles dataGridView1.MouseDown

    ' If the user right-clicks a cell, store it for use by the 
    ' shortcut menu.
    If e.Button = MouseButtons.Right Then
        Dim hit As DataGridView.HitTestInfo = _
            dataGridView1.HitTest(e.X, e.Y)
        If hit.Type = DataGridViewHitTestType.Cell Then
            clickedCell = _
                dataGridView1.Rows(hit.RowIndex).Cells(hit.ColumnIndex)
        End If
    End If

End Sub

적용 대상

추가 정보