DataGrid.HitTest Método
Definição
Sobrecargas
| HitTest(Int32, Int32) |
Obtém informações, como o número da linha e da coluna de um ponto clicado na grade, usando a coordenada x e y passada para o método.Gets information, such as row and column number of a clicked point on the grid, using the x and y coordinate passed to the method. |
| HitTest(Point) |
Obtém informações, como o número da linha e da coluna de um ponto clicado na grade, sobre a grade usando um Point específico.Gets information, such as row and column number of a clicked point on the grid, about the grid using a specific Point. |
HitTest(Int32, Int32)
Obtém informações, como o número da linha e da coluna de um ponto clicado na grade, usando a coordenada x e y passada para o método.Gets information, such as row and column number of a clicked point on the grid, using the x and y coordinate passed to the method.
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
Parâmetros
- x
- Int32
A posição horizontal da coordenada.The horizontal position of the coordinate.
- y
- Int32
A posição vertical da coordenada.The vertical position of the coordinate.
Retornos
Um DataGrid.HitTestInfo que contém informações sobre a parte clicada da grade.A DataGrid.HitTestInfo that contains information about the clicked part of the grid.
Exemplos
O exemplo de código a seguir usa o HitTest método em um evento que ocorre quando o usuário clica na grade.The following code example uses the HitTest method in an event that occurs when the user clicks in the grid.
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
Comentários
O DataGrid.HitTestInfo , em conjunto com o HitTest método do System.Windows.Forms.DataGrid controle, é usado para determinar qual parte de um System.Windows.Forms.DataGrid controle o usuário clicou.The DataGrid.HitTestInfo, in conjunction with the HitTest method of the System.Windows.Forms.DataGrid control, is used to determine which part of a System.Windows.Forms.DataGrid control the user has clicked. O DataGrid.HitTestInfo contém a linha, a coluna e a parte da grade que foi clicada.The DataGrid.HitTestInfo contains the row, column, and part of the grid that was clicked. Além disso, a Type propriedade retorna uma DataGrid.HitTestType enumeração.Additionally, the Type property returns a DataGrid.HitTestType enumeration.
O HitTest método usa um argumento x e y fornecido pelos eventos,,,, System.Windows.Forms.DataGrid e do controle DragDrop DragEnter DragOver MouseDown MouseMove MouseUp MouseWheel .The HitTest method takes an x and y argument supplied by the System.Windows.Forms.DataGrid control's DragDrop, DragEnter, DragOver, MouseDown, MouseMove, MouseUp and MouseWheel events.
Confira também
Aplica-se a
HitTest(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
Parâmetros
- position
- Point
Um Point que representa uma única coordenada x, y.A Point that represents single x,y coordinate.
Retornos
Um DataGrid.HitTestInfo que contém informações específicas sobre a grade.A DataGrid.HitTestInfo that contains specific information about the grid.
Exemplos
O exemplo de código a seguir usa o HitTest método em ocorre quando um usuário clica em uma grade.The following code example uses the HitTest method in occurs when a user clicks on a grid.
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
Comentários
O DataGrid.HitTestInfo , em conjunto com o HitTest método do System.Windows.Forms.DataGrid controle, é usado para determinar qual parte de um System.Windows.Forms.DataGrid controle o usuário clicou.The DataGrid.HitTestInfo, in conjunction with the HitTest method of the System.Windows.Forms.DataGrid control, is used to determine which part of a System.Windows.Forms.DataGrid control the user has clicked. O DataGrid.HitTestInfo contém a linha, a coluna e a parte da grade que foi clicada.The DataGrid.HitTestInfo contains the row, column, and part of the grid that was clicked. Além disso, a Type propriedade retorna uma DataGrid.HitTestType enumeração.Additionally, the Type property returns a DataGrid.HitTestType enumeration.
O HitTest método usa um argumento x e y fornecido pelos eventos,,,, System.Windows.Forms.DataGrid e do controle DragDrop DragEnter DragOver MouseDown MouseMove MouseUp MouseWheel .The HitTest method takes an x and y argument supplied by the System.Windows.Forms.DataGrid control's DragDrop, DragEnter, DragOver, MouseDown, MouseMove, MouseUp and MouseWheel events.