Sdílet prostřednictvím


DataGrid.HitTest Metoda

Definice

Získá informace o ovládacím DataGrid prvku v zadaném bodě na obrazovce.

Přetížení

Name Description
HitTest(Int32, Int32)

Získá informace, například řádek a sloupec číslo klikaný bod v mřížce pomocí souřadnice x a y předané metodě.

HitTest(Point)

Získá informace, například řádek a sloupec číslo klikaného bodu v mřížce, o mřížce pomocí konkrétního Point.

HitTest(Int32, Int32)

Zdroj:
DataGrid.cs
Zdroj:
DataGrid.cs

Získá informace, například řádek a sloupec číslo klikaný bod v mřížce pomocí souřadnice x a y předané metodě.

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

Parametry

x
Int32

Vodorovná pozice souřadnice.

y
Int32

Svislá pozice souřadnice.

Návraty

A DataGrid.HitTestInfo , který obsahuje informace o klikané části mřížky.

Příklady

Následující příklad kódu používá metodu HitTest v události, která nastane, když uživatel klikne v mřížce.

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

Poznámky

Ve DataGrid.HitTestInfospojení s metodou HitTestSystem.Windows.Forms.DataGrid ovládacího prvku se používá k určení, která část System.Windows.Forms.DataGrid ovládacího prvku uživatel kliknul. Obsahuje DataGrid.HitTestInfo řádek, sloupec a část mřížky, na kterou jsme klikli. Kromě toho Type vlastnost vrátí DataGrid.HitTestType výčet.

Metoda HitTest přebírá argument x a y zadaný ovládacím System.Windows.Forms.DataGrid prvku DragDrop, DragEnter, , DragOver, MouseUpMouseDownMouseMovea MouseWheel události.

Viz také

Platí pro

HitTest(Point)

Zdroj:
DataGrid.cs
Zdroj:
DataGrid.cs

Získá informace, například řádek a sloupec číslo klikaného bodu v mřížce, o mřížce pomocí konkrétního 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

Parametry

position
Point

A Point představující jednu souřadnici x,y.

Návraty

A DataGrid.HitTestInfo , která obsahuje konkrétní informace o mřížce.

Příklady

Následující příklad kódu používá metodu HitTest v případě, že uživatel klikne na mřížku.

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

Poznámky

Ve DataGrid.HitTestInfospojení s metodou HitTestSystem.Windows.Forms.DataGrid ovládacího prvku se používá k určení, která část System.Windows.Forms.DataGrid ovládacího prvku uživatel kliknul. Obsahuje DataGrid.HitTestInfo řádek, sloupec a část mřížky, na kterou jsme klikli. Kromě toho Type vlastnost vrátí DataGrid.HitTestType výčet.

Metoda HitTest přebírá argument x a y zadaný ovládacím System.Windows.Forms.DataGrid prvku DragDrop, DragEnter, , DragOver, MouseUpMouseDownMouseMovea MouseWheel události.

Viz také

Platí pro