DataGridView.HitTest 메서드
.NET Framework 2.0
참고: 이 메서드는 .NET Framework 버전 2.0에서 새로 추가되었습니다.
x 및 y 좌표가 지정된 경우, 행 인덱스 및 열 인덱스 등의 위치 정보를 반환합니다.
네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)
어셈블리: System.Windows.Forms(system.windows.forms.dll)
이 메서드를 사용하면 지정된 좌표에 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]; } } }
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.