다음을 통해 공유


DataGridView.HitTestInfo 클래스

정의

컨트롤의 특정 좌표 쌍 DataGridView 에 대한 행 및 열 인덱스와 같은 정보를 포함합니다. 이 클래스는 상속할 수 없습니다.

public: ref class DataGridView::HitTestInfo sealed
public sealed class DataGridView.HitTestInfo
type DataGridView.HitTestInfo = class
Public NotInheritable Class DataGridView.HitTestInfo
상속
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

설명

클래스DataGridView.HitTestInfoDataGridView 메서드는 HitTest . 이 메서드를 사용하여 컨트롤의 DataGridView 어느 부분이 지정된 좌표에 있는지 확인할 수 있습니다. 예를 들어 마우스 클릭의 좌표를 지정하는 이 메서드를 호출하여 클릭한 셀의 행 및 열 인덱스 또는 머리글 셀 또는 스크롤 막대를 클릭했는지 여부를 확인할 수 있습니다.

필드

Name Description
Nowhere

점이 셀 또는 셀 머리글에 있지 않도록 지정합니다. 이 필드는 읽기 전용입니다.

속성

Name Description
ColumnIndex

현재 DataGridView.HitTestInfo에서 설명하는 좌표를 포함하는 열의 인덱스를 가져옵니다.

ColumnX

현재 DataGridView.HitTestInfo에서 설명하는 좌표를 포함하는 열 시작 부분의 x 좌표를 가져옵니다.

RowIndex

현재 DataGridView.HitTestInfo에서 설명하는 좌표를 포함하는 행의 인덱스를 가져옵니다.

RowY

현재 DataGridView.HitTestInfo에서 설명하는 좌표를 포함하는 행 위쪽의 y 좌표를 가져옵니다.

Type

현재 DataGridView.HitTestInfo 에서 DataGridViewHitTestType 설명하는 좌표의 DataGridView 어느 부분이 속하는지 나타내는 해당 부분을 가져옵니다.

메서드

Name Description
Equals(Object)

지정된 Object 값이 현재 DataGridView.HitTestInfo와 같은지 여부를 확인합니다.

GetHashCode()

특정 형식에 대한 해시 함수로 사용됩니다.

GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

를 나타내는 문자열을 DataGridView.HitTestInfo반환합니다.

적용 대상

추가 정보