DataGrid.HitTestType Enumerazione

Definizione

Specifica la parte del controllo DataGrid su cui l'utente ha fatto clic.Specifies the part of the DataGrid control the user has clicked.

Questa enumerazione ha un attributo FlagsAttribute che consente una combinazione bit per bit dei valori del relativo membro.

public: enum class DataGrid::HitTestType
[System.Flags]
public enum DataGrid.HitTestType
type DataGrid.HitTestType = 
Public Enum DataGrid.HitTestType
Ereditarietà
DataGrid.HitTestType
Attributi

Campi

Caption 32

La didascalia del controllo DataGrid.The caption of the DataGrid control.

Cell 1

Cella nel controllo DataGrid.A cell in the DataGrid control.

ColumnHeader 2

Intestazione di colonna nel controllo DataGrid.A column header in the DataGrid control.

ColumnResize 8

Il bordo della colonna, ovvero la linea tra le intestazioni di colonna.The column border, which is the line between column headers. È possibile trascinarlo per ridimensionare la larghezza di una colonna.It can be dragged to resize a column's width.

None 0

L'area di sfondo, visibile quando il controllo non contiene tabelle, o contiene un numero limitato di righe, oppure quando una tabella viene fatta scorrere fino alla fine.The background area, visible when the control contains no table, few rows, or when a table is scrolled to its bottom.

ParentRows 64

La sezione di riga padre del controllo DataGrid.The parent row section of the DataGrid control. Nella riga padre vengono visualizzate le informazioni da o relative alla tabella padre della tabella figlio attualmente visualizzata, come il nome della tabella padre, i nomi delle colonne e i valori del record padre.The parent row displays information from or about the parent table of the currently displayed child table, such as the name of the parent table, column names and values of the parent record.

RowHeader 4

Intestazione di riga nel controllo DataGrid.A row header in the DataGrid control.

RowResize 16

Il bordo della riga, ovvero la linea tra le intestazioni di riga.The row border, which is the line between grid row headers. È possibile trascinarlo per ridimensionare l'altezza di una riga.It can be dragged to resize a row's height.

Esempi

Nell'esempio seguente viene usato HitTest il metodo in MouseDown un evento per restituire DataGrid.HitTestInfol'oggetto.The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo. Viene quindi stampata la riga, la colonna e la parte della griglia.The row, column, and part of the grid are then printed.

private:
   void dataGrid1_MouseDown( Object^ /*sender*/,
      System::Windows::Forms::MouseEventArgs^ e )
   {
      String^ newLine = "\n";
      Console::WriteLine( newLine );
      System::Windows::Forms::DataGrid::HitTestInfo^ myHitTest;
      // Use the DataGrid control's HitTest method with the x and y properties.
      myHitTest = dataGrid1->HitTest( e->X, e->Y );
      Console::WriteLine( myHitTest );
      Console::WriteLine( "Column {0}", myHitTest->Column );
      Console::WriteLine( "Row {0}", myHitTest->Row );
      Console::WriteLine( "Type {0}", myHitTest->Type );
      Console::WriteLine( "ToString {0}", myHitTest );
      Console::WriteLine( "Hit {0}", ReturnHitTest( myHitTest->Type ) );
   }

   String^ ReturnHitTest(
      System::Windows::Forms::DataGrid::HitTestType hit )
   {
      // Use this function to return the part of the grid clicked.   
      switch ( hit )
      {
      case(System::Windows::Forms::DataGrid::HitTestType::Cell):
         return "Cell";
       
      case(System::Windows::Forms::DataGrid::HitTestType::Caption):
         return "Caption";
       
      case(System::Windows::Forms::DataGrid::HitTestType::ColumnHeader):
          return "ColumnHeader";
          
      case(System::Windows::Forms::DataGrid::HitTestType::ColumnResize):
         return "Resize";
          
      case(System::Windows::Forms::DataGrid::HitTestType::ParentRows):
         return "ParentRows";
          
      case(System::Windows::Forms::DataGrid::HitTestType::RowHeader):
         return "RowHeader";
          
      case(System::Windows::Forms::DataGrid::HitTestType::RowResize):
         return "RowResize";
          
      case(System::Windows::Forms::DataGrid::HitTestType::None):
         return "None";

      default:
         return "Unknown";
      }
   }
private void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
   string newLine = "\n";
   Console.WriteLine(newLine);
   System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
   // Use the DataGrid control's HitTest method with the x and y properties.
   myHitTest = dataGrid1.HitTest(e.X,e.Y);
   Console.WriteLine(myHitTest);
   Console.WriteLine("Column " + myHitTest.Column);
   Console.WriteLine("Row " + myHitTest.Row);
   Console.WriteLine("Type " + myHitTest.Type);
   Console.WriteLine("ToString " + myHitTest.ToString());
   Console.WriteLine("Hit " + ReturnHitTest(myHitTest.Type ));
}
 
 private string ReturnHitTest(System.Windows.Forms.DataGrid.HitTestType  hit ){
    // Use this function to return the part of the grid clicked.   
    switch(hit) {
    case(System.Windows.Forms.DataGrid.HitTestType.Cell):
       return "Cell";

    case(System.Windows.Forms.DataGrid.HitTestType.Caption):
       return "Caption";
       
    case(System.Windows.Forms.DataGrid.HitTestType.ColumnHeader):
        return "ColumnHeader";
          
    case(System.Windows.Forms.DataGrid.HitTestType.ColumnResize):
       return "Resize";
          
    case(System.Windows.Forms.DataGrid.HitTestType.ParentRows):
       return "ParentRows";
          
    case(System.Windows.Forms.DataGrid.HitTestType.RowHeader):
       return "RowHeader";
          
    case(System.Windows.Forms.DataGrid.HitTestType.RowResize):
       return "RowResize";
          
    case(System.Windows.Forms.DataGrid.HitTestType.None):
       return "None";
    default:return "Unknown";
    }
 }

Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    Dim newLine As String = ControlChars.Cr
    Console.WriteLine(newLine)
    Dim myHitTest As System.Windows.Forms.DataGrid.HitTestInfo
    ' Use the DataGrid control's HitTest method with the x and y properties.
    myHitTest = dataGrid1.HitTest(e.X, e.Y)
    Console.WriteLine(myHitTest)
    Console.WriteLine(("Column " & myHitTest.Column))
    Console.WriteLine(("Row " & myHitTest.Row))
    Console.WriteLine(("Type " & myHitTest.Type))
    Console.WriteLine(("ToString " & myHitTest.ToString()))
    Console.WriteLine(("Hit " & ReturnHitTest(myHitTest.Type)))
End Sub


Private Function ReturnHitTest(hit As System.Windows.Forms.DataGrid.HitTestType) As String
    ' Use this function to return the part of the grid clicked.   
    Select Case hit
        Case System.Windows.Forms.DataGrid.HitTestType.Cell
                Return "Cell"
        
        Case System.Windows.Forms.DataGrid.HitTestType.Caption
                Return "Caption"
        
        Case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader
                Return "ColumnHeader"
        
        Case System.Windows.Forms.DataGrid.HitTestType.ColumnResize
                Return "Resize"
        
        Case System.Windows.Forms.DataGrid.HitTestType.ParentRows
                Return "ParentRows"
        
        Case System.Windows.Forms.DataGrid.HitTestType.RowHeader
                Return "RowHeader"
        
        Case System.Windows.Forms.DataGrid.HitTestType.RowResize
                Return "RowResize"
        
        Case System.Windows.Forms.DataGrid.HitTestType.None
                Return "None"
        Case Else
                Return "Unknown"
    End Select
End Function 'ReturnHitTest

Commenti

Usare i membri di questa enumerazione per determinare la parte della griglia su cui è stato fatto clic.Use the members of this enumeration to determine which part of the grid has been clicked. La Type proprietà di un DataGrid.HitTestInfo oggetto restituisce DataGrid.HitTestType.The Type property of a DataGrid.HitTestInfo returns a DataGrid.HitTestType. Viene creato richiamando il HitTest metodo di un System.Windows.Forms.DataGrid controllo. DataGrid.HitTestInfoThe DataGrid.HitTestInfo is created by invoking the HitTest method of a System.Windows.Forms.DataGrid control.

Si applica a

Vedi anche