DataGrid.HitTest 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
화면의 DataGrid 지정된 지점에서 컨트롤에 대한 정보를 가져옵니다.
오버로드
| Name | Description |
|---|---|
| HitTest(Int32, Int32) |
메서드에 전달된 x 및 y 좌표를 사용하여 그리드에서 클릭한 점의 행 및 열 번호와 같은 정보를 가져옵니다. |
| HitTest(Point) |
그리드에서 클릭한 점의 행 및 열 번호와 같은 특정 Point눈금에 대한 정보를 가져옵니다. |
HitTest(Int32, Int32)
- Source:
- DataGrid.cs
- Source:
- DataGrid.cs
메서드에 전달된 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 표에서 클릭한 부분에 대한 정보가 들어 있는 A입니다.
예제
다음 코드 예제에서는 사용자가 표에서 클릭할 때 발생 하는 이벤트에서 메서드를 사용 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컨트롤의 HitTestSystem.Windows.Forms.DataGrid 메서드와 함께 사용자가 클릭한 컨트롤의 System.Windows.Forms.DataGrid 일부를 결정하는 데 사용됩니다. DataGrid.HitTestInfo 클릭된 눈금의 행, 열 및 일부를 포함합니다. 또한 이 속성은 Type 열거형을 DataGrid.HitTestType 반환합니다.
이 메서드는 HitTest 컨트롤MouseDownDragEnterDragDropDragOverMouseMoveMouseUp, 및 이벤트에서 제공하는 System.Windows.Forms.DataGrid x 및 MouseWheel y 인수를 사용합니다.
추가 정보
적용 대상
HitTest(Point)
- Source:
- DataGrid.cs
- Source:
- DataGrid.cs
그리드에서 클릭한 점의 행 및 열 번호와 같은 특정 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
매개 변수
반환
표에 대한 특정 정보를 포함하는 A 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컨트롤의 HitTestSystem.Windows.Forms.DataGrid 메서드와 함께 사용자가 클릭한 컨트롤의 System.Windows.Forms.DataGrid 일부를 결정하는 데 사용됩니다. DataGrid.HitTestInfo 클릭된 눈금의 행, 열 및 일부를 포함합니다. 또한 이 속성은 Type 열거형을 DataGrid.HitTestType 반환합니다.
이 메서드는 HitTest 컨트롤MouseDownDragEnterDragDropDragOverMouseMoveMouseUp, 및 이벤트에서 제공하는 System.Windows.Forms.DataGrid x 및 MouseWheel y 인수를 사용합니다.