DataGrid.HitTestType Enumeração

Definição

Especifica a parte do controle DataGrid em que o usuário clicou.Specifies the part of the DataGrid control the user has clicked.

Esta enumeração tem um atributo FlagsAttribute que permite uma combinação bit a bit dos seus valores membros.

public: enum class DataGrid::HitTestType
[System.Flags]
public enum DataGrid.HitTestType
type DataGrid.HitTestType = 
Public Enum DataGrid.HitTestType
Herança
DataGrid.HitTestType
Atributos

Campos

Caption 32

A legenda do controle DataGrid.The caption of the DataGrid control.

Cell 1

Uma célula no controle DataGrid.A cell in the DataGrid control.

ColumnHeader 2

Um cabeçalho de coluna no controle DataGrid.A column header in the DataGrid control.

ColumnResize 8

A borda da coluna, que é a linha entre os cabeçalhos de coluna.The column border, which is the line between column headers. Ela pode ser arrastada para redimensionar a largura de uma coluna.It can be dragged to resize a column's width.

None 0

A área de tela de fundo, visível quando o controle não contém nenhuma tabela, algumas linhas ou quando uma tabela é rolada até sua parte inferior.The background area, visible when the control contains no table, few rows, or when a table is scrolled to its bottom.

ParentRows 64

Na seção de linha pai do controle DataGrid.The parent row section of the DataGrid control. A linha pai exibe informações de ou sobre a tabela pai da tabela filho atualmente exibida, como o nome da tabela pai, nomes de coluna e valores do registro pai.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

Um cabeçalho de linha no controle DataGrid.A row header in the DataGrid control.

RowResize 16

A borda da linha, que é a linha entre os cabeçalhos de linha de grade.The row border, which is the line between grid row headers. Ela pode ser arrastada para redimensionar altura de uma linha.It can be dragged to resize a row's height.

Exemplos

O exemplo a seguir usa HitTest o método em MouseDown um evento para retornar DataGrid.HitTestInfoo.The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo. A linha, a coluna e a parte da grade são então impressas.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

Comentários

Use os membros desta enumeração para determinar qual parte da grade foi clicada.Use the members of this enumeration to determine which part of the grid has been clicked. A Type propriedade de um DataGrid.HitTestInfo retorna um DataGrid.HitTestType.The Type property of a DataGrid.HitTestInfo returns a DataGrid.HitTestType. O DataGrid.HitTestInfo é criado invocando-se HitTest o método de System.Windows.Forms.DataGrid um controle.The DataGrid.HitTestInfo is created by invoking the HitTest method of a System.Windows.Forms.DataGrid control.

Aplica-se a

Veja também