DataGrid.HitTest 메서드

정의

화면의 지정된 지점에 있는 DataGrid 컨트롤에 대한 정보를 가져옵니다.

오버로드

HitTest(Int32, Int32)

메서드에 전달된 x, y 좌표를 사용하여 표에서 클릭된 지점의 행 및 열 번호와 같은 정보를 가져옵니다.

HitTest(Point)

특정 Point를 사용하여 표에서 클릭된 지점의 행 및 열 번호와 같은 표에 대한 정보를 가져옵니다.

HitTest(Int32, Int32)

메서드에 전달된 x, y 좌표를 사용하여 표에서 클릭된 지점의 행 및 열 번호와 같은 정보를 가져옵니다.

public:
 System::Windows::Forms::DataGrid::HitTestInfo ^ HitTest(int x, int y);
public System.Windows.Forms.DataGrid.HitTestInfo HitTest (int x, int y);
member this.HitTest : int * int -> System.Windows.Forms.DataGrid.HitTestInfo
Public Function HitTest (x As Integer, y As Integer) As DataGrid.HitTestInfo

매개 변수

x
Int32

좌표의 가로 위치입니다.

y
Int32

좌표의 세로 위치입니다.

반환

표의 클릭된 부분에 대한 정보가 들어 있는 DataGrid.HitTestInfo입니다.

예제

다음 코드 예제에서는 사용자가 그리드에서 클릭할 때 발생하는 이벤트에서 메서드를 사용합니다 HitTest .

Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim myGrid As DataGrid = CType(sender, DataGrid)
    Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
    hti = myGrid.HitTest(e.X, e.Y)
    Select Case hti.Type
    Case System.Windows.Forms.DataGrid.HitTestType.None 
       Console.WriteLine("You clicked the background.")
    Case System.Windows.Forms.DataGrid.HitTestType.Cell 
       Console.WriteLine("You clicked cell at row " & hti.Row & ", col " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader
       Console.WriteLine("You clicked the column header for column " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.RowHeader 
       Console.WriteLine("You clicked the row header for row " & hti.Row)
    Case System.Windows.Forms.DataGrid.HitTestType.ColumnResize
       Console.WriteLine("You clicked the column resizer for column " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.RowResize 
       Console.WriteLine("You clicked the row resizer for row " & hti.Row)
    Case System.Windows.Forms.DataGrid.HitTestType.Caption
       Console.WriteLine("You clicked the caption")
    Case System.Windows.Forms.DataGrid.HitTestType.ParentRows 
       Console.WriteLine("You clicked the parent row")
    End Select
 
 End Sub

설명

DataGrid.HitTestInfo컨트롤의 System.Windows.Forms.DataGrid 메서드와 함께 HitTest 는 사용자가 클릭한 컨트롤의 System.Windows.Forms.DataGrid 일부를 결정하는 데 사용됩니다. DataGrid.HitTestInfo 에는 클릭한 눈금의 행, 열 및 일부가 포함됩니다. 또한 속성은 Type 열거형을 DataGrid.HitTestType 반환합니다.

메서드는 HitTest 컨트롤의 DragDrop, MouseDownMouseUpDragEnterDragOverMouseMove및 이벤트에서 제공하는 System.Windows.Forms.DataGrid x 및 MouseWheel y 인수를 사용합니다.

추가 정보

적용 대상

HitTest(Point)

특정 Point를 사용하여 표에서 클릭된 지점의 행 및 열 번호와 같은 표에 대한 정보를 가져옵니다.

public:
 System::Windows::Forms::DataGrid::HitTestInfo ^ HitTest(System::Drawing::Point position);
public System.Windows.Forms.DataGrid.HitTestInfo HitTest (System.Drawing.Point position);
member this.HitTest : System.Drawing.Point -> System.Windows.Forms.DataGrid.HitTestInfo
Public Function HitTest (position As Point) As DataGrid.HitTestInfo

매개 변수

position
Point

단일 x, y 좌표를 나타내는 Point입니다.

반환

표에 대한 특정 정보가 들어 있는 DataGrid.HitTestInfo입니다.

예제

다음 코드 예제에서는 메서드를 HitTest 사용 합니다 에서 사용자가 그리드를 클릭할 때 발생 합니다.

Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim hti As DataGrid.HitTestInfo
    hti = grid.HitTest(New Point(e.X, e.Y))
    Select Case hti.Type
    Case System.Windows.Forms.DataGrid.HitTestType.None 
       Console.WriteLine("You clicked the background.")
    Case System.Windows.Forms.DataGrid.HitTestType.Cell 
       Console.WriteLine("You clicked cell at row " & hti.Row & ", col " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader
       Console.WriteLine("You clicked the column header for column " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.RowHeader 
       Console.WriteLine("You clicked the row header for row " & hti.Row)
    Case System.Windows.Forms.DataGrid.HitTestType.ColumnResize
       Console.WriteLine("You clicked the column resizer for column " & hti.Column)
    Case System.Windows.Forms.DataGrid.HitTestType.RowResize 
       Console.WriteLine("You clicked the row resizer for row " & hti.Row)
    Case System.Windows.Forms.DataGrid.HitTestType.Caption
       Console.WriteLine("You clicked the caption")
    Case System.Windows.Forms.DataGrid.HitTestType.ParentRows 
       Console.WriteLine("You clicked the parent row")
    End Select
 End Sub

설명

DataGrid.HitTestInfo컨트롤의 System.Windows.Forms.DataGrid 메서드와 함께 HitTest 는 사용자가 클릭한 컨트롤의 System.Windows.Forms.DataGrid 일부를 결정하는 데 사용됩니다. DataGrid.HitTestInfo 에는 클릭한 눈금의 행, 열 및 일부가 포함됩니다. 또한 속성은 Type 열거형을 DataGrid.HitTestType 반환합니다.

메서드는 HitTest 컨트롤의 DragDrop, MouseDownMouseUpDragEnterDragOverMouseMove및 이벤트에서 제공하는 System.Windows.Forms.DataGrid x 및 MouseWheel y 인수를 사용합니다.

추가 정보

적용 대상