DataGrid.HitTest Metoda

Definice

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

Přetížení

HitTest(Int32, Int32)

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

HitTest(Point)

Získá informace o mřížce, například číslo řádku a sloupce klepaného bodu v mřížce pomocí konkrétního Pointobjektu .

HitTest(Int32, Int32)

Získá informace, například řádek a sloupec číslo klepnul bod v mřížce pomocí souřadnic 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á poloha 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, ke které dojde, když uživatel klikne do mřížky.

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í části System.Windows.Forms.DataGrid ovládacího prvku, na kterou uživatel kliknul. Obsahuje DataGrid.HitTestInfo řádek, sloupec a část mřížky, na kterou bylo kliknutí. Kromě toho Type vlastnost vrátí DataGrid.HitTestType výčet.

Metoda HitTest přebírá argumenty x a y zadané událostmi System.Windows.Forms.DataGrid , , DragEnter, DragOverMouseDown, MouseMoveMouseUp a MouseWheel ovládacího prvkuDragDrop.

Viz také

Platí pro

HitTest(Point)

Získá informace o mřížce, například číslo řádku a sloupce klepaného bodu v mřížce pomocí konkrétního Pointobjektu .

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 , která představuje 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 nastane, když 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í části System.Windows.Forms.DataGrid ovládacího prvku, na kterou uživatel kliknul. Obsahuje DataGrid.HitTestInfo řádek, sloupec a část mřížky, na kterou bylo kliknutí. Kromě toho Type vlastnost vrátí DataGrid.HitTestType výčet.

Metoda HitTest přebírá argumenty x a y zadané událostmi System.Windows.Forms.DataGrid , , DragEnter, DragOverMouseDown, MouseMoveMouseUp a MouseWheel ovládacího prvkuDragDrop.

Viz také

Platí pro