DataGrid.HitTestType DataGrid.HitTestType DataGrid.HitTestType DataGrid.HitTestType Enum

定義

DataGrid コントロール内でユーザーがクリックした部分を指定します。Specifies the part of the DataGrid control the user has clicked.

この列挙型には FlagsAttribute 属性があり、メンバー値ではビットごとの組み合わせを使用できます。

public: enum class DataGrid::HitTestType
[System.Flags]
public enum DataGrid.HitTestType
type DataGrid.HitTestType = 
Public Enum DataGrid.HitTestType
継承
DataGrid.HitTestTypeDataGrid.HitTestTypeDataGrid.HitTestTypeDataGrid.HitTestType
属性

フィールド

Caption Caption Caption Caption 32

DataGrid コントロールのキャプション。The caption of the DataGrid control.

Cell Cell Cell Cell 1

DataGrid コントロール内のセル。A cell in the DataGrid control.

ColumnHeader ColumnHeader ColumnHeader ColumnHeader 2

DataGrid コントロール内の列ヘッダー。A column header in the DataGrid control.

ColumnResize ColumnResize ColumnResize ColumnResize 8

列ヘッダーの間に表示される列の境界線。The column border, which is the line between column headers. この境界線をドラッグすると、列の幅を変更できます。It can be dragged to resize a column's width.

None None None None 0

背景領域。コントロールにテーブルがない場合、行が少ししかない場合、またはテーブルを下部までスクロールした場合に表示されます。The background area, visible when the control contains no table, few rows, or when a table is scrolled to its bottom.

ParentRows ParentRows ParentRows ParentRows 64

DataGrid コントロールの親行セクション。The parent row section of the DataGrid control. 親行には、現在表示されている子テーブルの親テーブルに関する情報 (親テーブルの名前、親レコードの列の名前や値など) が表示されます。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 RowHeader RowHeader RowHeader 4

DataGrid コントロール内の行ヘッダー。A row header in the DataGrid control.

RowResize RowResize RowResize RowResize 16

行ヘッダーの間に表示される行の境界線。The row border, which is the line between grid row headers. この境界線をドラッグすると、行の高さを変更できます。It can be dragged to resize a row's height.

次の例では、HitTestメソッドで、MouseDownに返すイベント、DataGrid.HitTestInfoします。The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo. 行、列、およびグリッドの一部が出力されます。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 'dataGrid1_MouseDown


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

注釈

この列挙体のメンバーを使用すると、グリッドのどの部分がクリックしてされたかを判断します。Use the members of this enumeration to determine which part of the grid has been clicked. TypeのプロパティをDataGrid.HitTestInfoを返します、DataGrid.HitTestTypeします。The Type property of a DataGrid.HitTestInfo returns a DataGrid.HitTestType. DataGrid.HitTestInfoを呼び出すことによって作成されたが、HitTestのメソッドをSystem.Windows.Forms.DataGridコントロール。The DataGrid.HitTestInfo is created by invoking the HitTest method of a System.Windows.Forms.DataGrid control.

適用対象

こちらもご覧ください