DataGrid 类

定义

在可滚动的网格中显示 ADO.NET 数据。Displays ADO.NET data in a scrollable grid. DataGridView 控件取代了 DataGrid 控件并添加了功能;但是,可以选择保留 DataGrid 控件以实现向后兼容并供将来使用。The DataGridView control replaces and adds functionality to the DataGrid control; however, the DataGrid control is retained for both backward compatibility and future use, if you choose.

public ref class DataGrid : System::Windows::Forms::Control, System::ComponentModel::ISupportInitialize, System::Windows::Forms::IDataGridEditingService
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
public class DataGrid : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize, System.Windows.Forms.IDataGridEditingService
type DataGrid = class
    inherit Control
    interface ISupportInitialize
    interface IDataGridEditingService
Public Class DataGrid
Inherits Control
Implements IDataGridEditingService, ISupportInitialize
继承
属性
实现

示例

下面的代码示例创建一个 Windows 窗体、一个包含两个 @no__t 对象的 @no__t 0 和一个与这两个表关联的 DataRelationThe following code example creates a Windows form, a DataSet containing two DataTable objects, and a DataRelation that relates the two tables. 若要显示数据,可通过 SetDataBinding 方法将 @no__t 0 的控件绑定到 @no__t 1。To display the data, a System.Windows.Forms.DataGrid control is then bound to the DataSet through the SetDataBinding method. 窗体上的按钮通过创建两个 @no__t 0 个对象并将每个对象的 @no__t 设置为一个 @no__t 3 对象的第 2 @no__t,来更改网格的外观。A button on the form changes the appearance of the grid by creating two DataGridTableStyle objects and setting the MappingName of each object to a TableName of one of the DataTable objects. 该示例还包含 MouseUp 事件中的代码,该代码使用 HitTest 方法来打印已单击的网格的列、行和部分。The example also contains code in the MouseUp event that uses the HitTest method to print the column, row, and part of the grid that has been clicked.

#using <system.dll>
#using <system.data.dll>
#using <system.drawing.dll>
#using <system.windows.forms.dll>
#using <system.xml.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Windows::Forms;

#define null 0
public ref class Form1: public System::Windows::Forms::Form
{
private:
   System::ComponentModel::Container^ components;
   Button^ button1;
   Button^ button2;
   DataGrid^ myDataGrid;
   DataSet^ myDataSet;
   bool TablesAlreadyAdded;

public:
   Form1()
   {
      // Required for Windows Form Designer support.
      InitializeComponent();

      // Call SetUp to bind the controls.
      SetUp();
   }

public:
   ~Form1()
   {
      if ( components != nullptr )
      {
         delete components;
      }
   }

private:
   void InitializeComponent()
   {
      // Create the form and its controls.
      this->components = gcnew System::ComponentModel::Container;
      this->button1 = gcnew System::Windows::Forms::Button;
      this->button2 = gcnew System::Windows::Forms::Button;
      this->myDataGrid = gcnew DataGrid;
      this->Text = "DataGrid Control Sample";
      this->ClientSize = System::Drawing::Size( 450, 330 );
      button1->Location = System::Drawing::Point( 24, 16 );
      button1->Size = System::Drawing::Size( 120, 24 );
      button1->Text = "Change Appearance";
      button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click );
      button2->Location = System::Drawing::Point( 150, 16 );
      button2->Size = System::Drawing::Size( 120, 24 );
      button2->Text = "Get Binding Manager";
      button2->Click += gcnew System::EventHandler( this, &Form1::button2_Click );
      myDataGrid->Location = System::Drawing::Point( 24, 50 );
      myDataGrid->Size = System::Drawing::Size( 300, 200 );
      myDataGrid->CaptionText = "Microsoft DataGrid Control";
      myDataGrid->MouseUp += gcnew MouseEventHandler( this, &Form1::Grid_MouseUp );
      this->Controls->Add( button1 );
      this->Controls->Add( button2 );
      this->Controls->Add( myDataGrid );
   }

   void SetUp()
   {
      // Create a DataSet with two tables and one relation.
      MakeDataSet();

      /* Bind the DataGrid to the DataSet. The dataMember
        specifies that the Customers table should be displayed.*/
      myDataGrid->SetDataBinding( myDataSet, "Customers" );
   }

private:
   void button1_Click( Object^ sender, System::EventArgs^ e )
   {
      if ( TablesAlreadyAdded )
            return;

      AddCustomDataTableStyle();
   }

private:
   void AddCustomDataTableStyle()
   {
      DataGridTableStyle^ ts1 = gcnew DataGridTableStyle;
      ts1->MappingName = "Customers";

      // Set other properties.
      ts1->AlternatingBackColor = Color::LightGray;

      /* Add a GridColumnStyle and set its MappingName 
        to the name of a DataColumn in the DataTable. 
        Set the HeaderText and Width properties. */
      DataGridColumnStyle^ boolCol = gcnew DataGridBoolColumn;
      boolCol->MappingName = "Current";
      boolCol->HeaderText = "IsCurrent Customer";
      boolCol->Width = 150;
      ts1->GridColumnStyles->Add( boolCol );

      // Add a second column style.
      DataGridColumnStyle^ TextCol = gcnew DataGridTextBoxColumn;
      TextCol->MappingName = "custName";
      TextCol->HeaderText = "Customer Name";
      TextCol->Width = 250;
      ts1->GridColumnStyles->Add( TextCol );

      // Create the second table style with columns.
      DataGridTableStyle^ ts2 = gcnew DataGridTableStyle;
      ts2->MappingName = "Orders";

      // Set other properties.
      ts2->AlternatingBackColor = Color::LightBlue;

      // Create new ColumnStyle objects
      DataGridColumnStyle^ cOrderDate = gcnew DataGridTextBoxColumn;
      cOrderDate->MappingName = "OrderDate";
      cOrderDate->HeaderText = "Order Date";
      cOrderDate->Width = 100;
      ts2->GridColumnStyles->Add( cOrderDate );

      /* Use a PropertyDescriptor to create a formatted
        column. First get the PropertyDescriptorCollection
        for the data source and data member. */
      PropertyDescriptorCollection^ pcol = this->BindingContext[myDataSet, "Customers.custToOrders"]->GetItemProperties();

      /* Create a formatted column using a PropertyDescriptor.
        The formatting character "c" specifies a currency format. */
      DataGridColumnStyle^ csOrderAmount = gcnew DataGridTextBoxColumn( pcol[ "OrderAmount" ],"c",true );
      csOrderAmount->MappingName = "OrderAmount";
      csOrderAmount->HeaderText = "Total";
      csOrderAmount->Width = 100;
      ts2->GridColumnStyles->Add( csOrderAmount );

      /* Add the DataGridTableStyle instances to 
        the GridTableStylesCollection. */
      myDataGrid->TableStyles->Add( ts1 );
      myDataGrid->TableStyles->Add( ts2 );

      // Sets the TablesAlreadyAdded to true so this doesn't happen again.
      TablesAlreadyAdded = true;
   }

private:
   void button2_Click( Object^ sender, System::EventArgs^ e )
   {
      BindingManagerBase^ bmGrid;
      bmGrid = BindingContext[myDataSet, "Customers"];
      MessageBox::Show( String::Concat( "Current BindingManager Position: ", bmGrid->Position )->ToString() );
   }

private:
   void Grid_MouseUp( Object^ sender, MouseEventArgs^ e )
   {
      // Create a HitTestInfo object using the HitTest method.
      // Get the DataGrid by casting sender.
      DataGrid^ myGrid = dynamic_cast<DataGrid^>(sender);
      DataGrid::HitTestInfo ^ myHitInfo = myGrid->HitTest( e->X, e->Y );
      Console::WriteLine( myHitInfo );
      Console::WriteLine( myHitInfo->Type );
      Console::WriteLine( myHitInfo->Row );
      Console::WriteLine( myHitInfo->Column );
   }

   // Create a DataSet with two tables and populate it.
   void MakeDataSet()
   {
      // Create a DataSet.
      myDataSet = gcnew DataSet( "myDataSet" );

      // Create two DataTables.
      DataTable^ tCust = gcnew DataTable( "Customers" );
      DataTable^ tOrders = gcnew DataTable( "Orders" );

      // Create two columns, and add them to the first table.
      DataColumn^ cCustID = gcnew DataColumn( "CustID",__int32::typeid );
      DataColumn^ cCustName = gcnew DataColumn( "CustName" );
      DataColumn^ cCurrent = gcnew DataColumn( "Current",bool::typeid );
      tCust->Columns->Add( cCustID );
      tCust->Columns->Add( cCustName );
      tCust->Columns->Add( cCurrent );

      // Create three columns, and add them to the second table.
      DataColumn^ cID = gcnew DataColumn( "CustID",__int32::typeid );
      DataColumn^ cOrderDate = gcnew DataColumn( "orderDate",DateTime::typeid );
      DataColumn^ cOrderAmount = gcnew DataColumn( "OrderAmount",Decimal::typeid );
      tOrders->Columns->Add( cOrderAmount );
      tOrders->Columns->Add( cID );
      tOrders->Columns->Add( cOrderDate );

      // Add the tables to the DataSet.
      myDataSet->Tables->Add( tCust );
      myDataSet->Tables->Add( tOrders );

      // Create a DataRelation, and add it to the DataSet.
      DataRelation^ dr = gcnew DataRelation( "custToOrders",cCustID,cID );
      myDataSet->Relations->Add( dr );

      /* Populate the tables. For each customer and order, 
        create need two DataRow variables. */
      DataRow^ newRow1;
      DataRow^ newRow2;

      // Create three customers in the Customers Table.
      for ( int i = 1; i < 4; i++ )
      {
         newRow1 = tCust->NewRow();
         newRow1[ "custID" ] = i;
         
         // Add the row to the Customers table.
         tCust->Rows->Add( newRow1 );
      }
      tCust->Rows[ 0 ][ "custName" ] = "Customer1";
      tCust->Rows[ 1 ][ "custName" ] = "Customer2";
      tCust->Rows[ 2 ][ "custName" ] = "Customer3";

      // Give the Current column a value.
      tCust->Rows[ 0 ][ "Current" ] = true;
      tCust->Rows[ 1 ][ "Current" ] = true;
      tCust->Rows[ 2 ][ "Current" ] = false;

      // For each customer, create five rows in the Orders table.
      for ( int i = 1; i < 4; i++ )
      {
         for ( int j = 1; j < 6; j++ )
         {
            newRow2 = tOrders->NewRow();
            newRow2[ "CustID" ] = i;
            newRow2[ "orderDate" ] = DateTime(2001,i,j * 2);
            newRow2[ "OrderAmount" ] = i * 10 + j * .1;
            
            // Add the row to the Orders table.
            tOrders->Rows->Add( newRow2 );
         }
      }
   }
};

int main()
{
   Application::Run( gcnew Form1 );
}
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
   private System.ComponentModel.Container components;
   private Button button1;
   private Button button2;
   private DataGrid myDataGrid;   
   private DataSet myDataSet;
   private bool TablesAlreadyAdded;
   public Form1()
   {
      // Required for Windows Form Designer support.
      InitializeComponent();
      // Call SetUp to bind the controls.
      SetUp();
   }

   protected override void Dispose( bool disposing ){
      if( disposing ){
         if (components != null){
            components.Dispose();}
      }
      base.Dispose( disposing );
   }
   private void InitializeComponent()
   {
      // Create the form and its controls.
      this.components = new System.ComponentModel.Container();
      this.button1 = new System.Windows.Forms.Button();
      this.button2 = new System.Windows.Forms.Button();
      this.myDataGrid = new DataGrid();
      
      this.Text = "DataGrid Control Sample";
      this.ClientSize = new System.Drawing.Size(450, 330);
      
      button1.Location = new Point(24, 16);
      button1.Size = new System.Drawing.Size(120, 24);
      button1.Text = "Change Appearance";
      button1.Click+=new System.EventHandler(button1_Click);

      button2.Location = new Point(150, 16);
      button2.Size = new System.Drawing.Size(120, 24);
      button2.Text = "Get Binding Manager";
      button2.Click+=new System.EventHandler(button2_Click);

      myDataGrid.Location = new  Point(24, 50);
      myDataGrid.Size = new Size(300, 200);
      myDataGrid.CaptionText = "Microsoft DataGrid Control";
      myDataGrid.MouseUp += new MouseEventHandler(Grid_MouseUp);
      
      this.Controls.Add(button1);
      this.Controls.Add(button2);
      this.Controls.Add(myDataGrid);
   }

   public static void Main()
   {
      Application.Run(new Form1());
   }
   
   private void SetUp()
   {
      // Create a DataSet with two tables and one relation.
      MakeDataSet();
      /* Bind the DataGrid to the DataSet. The dataMember
      specifies that the Customers table should be displayed.*/
      myDataGrid.SetDataBinding(myDataSet, "Customers");
   }

   private void button1_Click(object sender, System.EventArgs e)
   {
      if(TablesAlreadyAdded) return;
      AddCustomDataTableStyle();
   }

   private void AddCustomDataTableStyle()
   {
      DataGridTableStyle ts1 = new DataGridTableStyle();
      ts1.MappingName = "Customers";
      // Set other properties.
      ts1.AlternatingBackColor = Color.LightGray;

      /* Add a GridColumnStyle and set its MappingName 
      to the name of a DataColumn in the DataTable. 
      Set the HeaderText and Width properties. */
      
      DataGridColumnStyle boolCol = new DataGridBoolColumn();
      boolCol.MappingName = "Current";
      boolCol.HeaderText = "IsCurrent Customer";
      boolCol.Width = 150;
      ts1.GridColumnStyles.Add(boolCol);
      
      // Add a second column style.
      DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
      TextCol.MappingName = "custName";
      TextCol.HeaderText = "Customer Name";
      TextCol.Width = 250;
      ts1.GridColumnStyles.Add(TextCol);

      // Create the second table style with columns.
      DataGridTableStyle ts2 = new DataGridTableStyle();
      ts2.MappingName = "Orders";

      // Set other properties.
      ts2.AlternatingBackColor = Color.LightBlue;
      
      // Create new ColumnStyle objects
      DataGridColumnStyle cOrderDate = 
      new DataGridTextBoxColumn();
      cOrderDate.MappingName = "OrderDate";
      cOrderDate.HeaderText = "Order Date";
      cOrderDate.Width = 100;
      ts2.GridColumnStyles.Add(cOrderDate);

      /* Use a PropertyDescriptor to create a formatted
      column. First get the PropertyDescriptorCollection
      for the data source and data member. */
      PropertyDescriptorCollection pcol = this.BindingContext
      [myDataSet, "Customers.custToOrders"].GetItemProperties();
 
      /* Create a formatted column using a PropertyDescriptor.
      The formatting character "c" specifies a currency format. */     
      DataGridColumnStyle csOrderAmount = 
      new DataGridTextBoxColumn(pcol["OrderAmount"], "c", true);
      csOrderAmount.MappingName = "OrderAmount";
      csOrderAmount.HeaderText = "Total";
      csOrderAmount.Width = 100;
      ts2.GridColumnStyles.Add(csOrderAmount);

      /* Add the DataGridTableStyle instances to 
      the GridTableStylesCollection. */
      myDataGrid.TableStyles.Add(ts1);
      myDataGrid.TableStyles.Add(ts2);

     // Sets the TablesAlreadyAdded to true so this doesn't happen again.
     TablesAlreadyAdded=true;
   }

   private void button2_Click(object sender, System.EventArgs e)
   {
      BindingManagerBase bmGrid;
      bmGrid = BindingContext[myDataSet, "Customers"];
      MessageBox.Show("Current BindingManager Position: " + bmGrid.Position);
   }

   private void Grid_MouseUp(object sender, MouseEventArgs e)
   {
      // Create a HitTestInfo object using the HitTest method.

      // Get the DataGrid by casting sender.
      DataGrid myGrid = (DataGrid)sender;
      DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, e.Y);
      Console.WriteLine(myHitInfo);
      Console.WriteLine(myHitInfo.Type);
      Console.WriteLine(myHitInfo.Row);
      Console.WriteLine(myHitInfo.Column);
   }

   // Create a DataSet with two tables and populate it.
   private void MakeDataSet()
   {
      // Create a DataSet.
      myDataSet = new DataSet("myDataSet");
      
      // Create two DataTables.
      DataTable tCust = new DataTable("Customers");
      DataTable tOrders = new DataTable("Orders");

      // Create two columns, and add them to the first table.
      DataColumn cCustID = new DataColumn("CustID", typeof(int));
      DataColumn cCustName = new DataColumn("CustName");
      DataColumn cCurrent = new DataColumn("Current", typeof(bool));
      tCust.Columns.Add(cCustID);
      tCust.Columns.Add(cCustName);
      tCust.Columns.Add(cCurrent);

      // Create three columns, and add them to the second table.
      DataColumn cID = 
      new DataColumn("CustID", typeof(int));
      DataColumn cOrderDate = 
      new DataColumn("orderDate",typeof(DateTime));
      DataColumn cOrderAmount = 
      new DataColumn("OrderAmount", typeof(decimal));
      tOrders.Columns.Add(cOrderAmount);
      tOrders.Columns.Add(cID);
      tOrders.Columns.Add(cOrderDate);

      // Add the tables to the DataSet.
      myDataSet.Tables.Add(tCust);
      myDataSet.Tables.Add(tOrders);

      // Create a DataRelation, and add it to the DataSet.
      DataRelation dr = new DataRelation
      ("custToOrders", cCustID , cID);
      myDataSet.Relations.Add(dr);
   
      /* Populates the tables. For each customer and order, 
      creates two DataRow variables. */
      DataRow newRow1;
      DataRow newRow2;

      // Create three customers in the Customers Table.
      for(int i = 1; i < 4; i++)
      {
         newRow1 = tCust.NewRow();
         newRow1["custID"] = i;
         // Add the row to the Customers table.
         tCust.Rows.Add(newRow1);
      }
      // Give each customer a distinct name.
      tCust.Rows[0]["custName"] = "Customer1";
      tCust.Rows[1]["custName"] = "Customer2";
      tCust.Rows[2]["custName"] = "Customer3";

      // Give the Current column a value.
      tCust.Rows[0]["Current"] = true;
      tCust.Rows[1]["Current"] = true;
      tCust.Rows[2]["Current"] = false;

      // For each customer, create five rows in the Orders table.
      for(int i = 1; i < 4; i++)
      {
         for(int j = 1; j < 6; j++)
         {
            newRow2 = tOrders.NewRow();
            newRow2["CustID"]= i;
            newRow2["orderDate"]= new DateTime(2001, i, j * 2);
            newRow2["OrderAmount"] = i * 10 + j  * .1;
            // Add the row to the Orders table.
            tOrders.Rows.Add(newRow2);
         }
      }
   }
}
Option Explicit
Option Strict

Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
   Inherits System.Windows.Forms.Form
   Private components As System.ComponentModel.Container
   Private button1 As Button
   Private button2 As Button
   Private myDataGrid As DataGrid
   Private myDataSet As DataSet
   Private TablesAlreadyAdded As Boolean    
    
   Public Sub New()
      ' Required for Windows Form Designer support.
      InitializeComponent()
      ' Call SetUp to bind the controls.
      SetUp()
   End Sub 
        
  Private Sub InitializeComponent()
      ' Create the form and its controls.
      Me.components = New System.ComponentModel.Container()
      Me.button1 = New System.Windows.Forms.Button()
      Me.button2 = New System.Windows.Forms.Button()
      Me.myDataGrid = New DataGrid()
      
      Me.Text = "DataGrid Control Sample"
      Me.ClientSize = New System.Drawing.Size(450, 330)
        
      button1.Location = New Point(24, 16)
      button1.Size = New System.Drawing.Size(120, 24)
      button1.Text = "Change Appearance"
      AddHandler button1.Click, AddressOf button1_Click
        
      button2.Location = New Point(150, 16)
      button2.Size = New System.Drawing.Size(120, 24)
      button2.Text = "Get Binding Manager"
      AddHandler button2.Click, AddressOf button2_Click
        
      myDataGrid.Location = New Point(24, 50)
      myDataGrid.Size = New Size(300, 200)
      myDataGrid.CaptionText = "Microsoft DataGrid Control"
      AddHandler myDataGrid.MouseUp, AddressOf Grid_MouseUp
        
      Me.Controls.Add(button1)
      Me.Controls.Add(button2)
      Me.Controls.Add(myDataGrid)
   End Sub 
    
   Public Shared Sub Main()
      Application.Run(New Form1())
   End Sub 
        
   Private Sub SetUp()
      ' Create a DataSet with two tables and one relation.
      MakeDataSet()
      ' Bind the DataGrid to the DataSet. The dataMember
      ' specifies that the Customers table should be displayed.
      myDataGrid.SetDataBinding(myDataSet, "Customers")
   End Sub 
        
    Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If TablesAlreadyAdded = True Then Exit Sub
        AddCustomDataTableStyle()
    End Sub
   
   Private Sub AddCustomDataTableStyle()
      Dim ts1 As New DataGridTableStyle()
      ts1.MappingName = "Customers"
      ' Set other properties.
      ts1.AlternatingBackColor = Color.LightGray
      ' Add a GridColumnStyle and set its MappingName 
      ' to the name of a DataColumn in the DataTable. 
      ' Set the HeaderText and Width properties. 
        
      Dim boolCol As New DataGridBoolColumn()
      boolCol.MappingName = "Current"
      boolCol.HeaderText = "IsCurrent Customer"
      boolCol.Width = 150
      ts1.GridColumnStyles.Add(boolCol)
        
      ' Add a second column style.
      Dim TextCol As New DataGridTextBoxColumn()
      TextCol.MappingName = "custName"
      TextCol.HeaderText = "Customer Name"
      TextCol.Width = 250
      ts1.GridColumnStyles.Add(TextCol)
        
      ' Create the second table style with columns.
      Dim ts2 As New DataGridTableStyle()
      ts2.MappingName = "Orders"
        
      ' Set other properties.
      ts2.AlternatingBackColor = Color.LightBlue
        
      ' Create new ColumnStyle objects
      Dim cOrderDate As New DataGridTextBoxColumn()
      cOrderDate.MappingName = "OrderDate"
      cOrderDate.HeaderText = "Order Date"
      cOrderDate.Width = 100
      ts2.GridColumnStyles.Add(cOrderDate)

      ' Use a PropertyDescriptor to create a formatted
      ' column. First get the PropertyDescriptorCollection
      ' for the data source and data member. 
      Dim pcol As PropertyDescriptorCollection = _
      Me.BindingContext(myDataSet, "Customers.custToOrders"). _
      GetItemProperties()

      ' Create a formatted column using a PropertyDescriptor.
      ' The formatting character "c" specifies a currency format. */     
        
      Dim csOrderAmount As _
      New DataGridTextBoxColumn(pcol("OrderAmount"), "c", True)
      csOrderAmount.MappingName = "OrderAmount"
      csOrderAmount.HeaderText = "Total"
      csOrderAmount.Width = 100
      ts2.GridColumnStyles.Add(csOrderAmount)
        
      ' Add the DataGridTableStyle instances to 
      ' the GridTableStylesCollection. 
      myDataGrid.TableStyles.Add(ts1)
      myDataGrid.TableStyles.Add(ts2)

     ' Sets the TablesAlreadyAdded to true so this doesn't happen again.
      TablesAlreadyAdded = true
   End Sub 
    
    Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim bmGrid As BindingManagerBase
        bmGrid = BindingContext(myDataSet, "Customers")
        MessageBox.Show(("Current BindingManager Position: " & bmGrid.Position))
    End Sub
        
   Private Sub Grid_MouseUp(sender As Object, e As MouseEventArgs)
      ' Create a HitTestInfo object using the HitTest method.
      ' Get the DataGrid by casting sender.
      Dim myGrid As DataGrid = CType(sender, DataGrid)
      Dim myHitInfo As DataGrid.HitTestInfo = myGrid.HitTest(e.X, e.Y)
      Console.WriteLine(myHitInfo)
      Console.WriteLine(myHitInfo.Type)
      Console.WriteLine(myHitInfo.Row)
      Console.WriteLine(myHitInfo.Column)
   End Sub 
        
   ' Create a DataSet with two tables and populate it.
   Private Sub MakeDataSet()
      ' Create a DataSet.
      myDataSet = New DataSet("myDataSet")
       
      ' Create two DataTables.
      Dim tCust As New DataTable("Customers")
      Dim tOrders As New DataTable("Orders")
      
      ' Create two columns, and add them to the first table.
      Dim cCustID As New DataColumn("CustID", GetType(Integer))
      Dim cCustName As New DataColumn("CustName")
      Dim cCurrent As New DataColumn("Current", GetType(Boolean))
      tCust.Columns.Add(cCustID)
      tCust.Columns.Add(cCustName)
      tCust.Columns.Add(cCurrent)
       
      ' Create three columns, and add them to the second table.
      Dim cID As New DataColumn("CustID", GetType(Integer))
      Dim cOrderDate As New DataColumn("orderDate", GetType(DateTime))
      Dim cOrderAmount As New DataColumn("OrderAmount", GetType(Decimal))
      tOrders.Columns.Add(cOrderAmount)
      tOrders.Columns.Add(cID)
      tOrders.Columns.Add(cOrderDate)
       
      ' Add the tables to the DataSet.
      myDataSet.Tables.Add(tCust)
      myDataSet.Tables.Add(tOrders)
        
      ' Create a DataRelation, and add it to the DataSet.
      Dim dr As New DataRelation("custToOrders", cCustID, cID)
      myDataSet.Relations.Add(dr)
        
      ' Populates the tables. For each customer and order, 
      ' creates two DataRow variables. 
      Dim newRow1 As DataRow
      Dim newRow2 As DataRow
        
      ' Create three customers in the Customers Table.
      Dim i As Integer
      For i = 1 To 3
         newRow1 = tCust.NewRow()
         newRow1("custID") = i
         ' Add the row to the Customers table.
         tCust.Rows.Add(newRow1)
      Next i
      ' Give each customer a distinct name.
      tCust.Rows(0)("custName") = "Customer1"
      tCust.Rows(1)("custName") = "Customer2"
      tCust.Rows(2)("custName") = "Customer3"
        
      ' Give the Current column a value.
      tCust.Rows(0)("Current") = True
      tCust.Rows(1)("Current") = True
      tCust.Rows(2)("Current") = False
        
      ' For each customer, create five rows in the Orders table.
      For i = 1 To 3
         Dim j As Integer
         For j = 1 To 5
            newRow2 = tOrders.NewRow()
            newRow2("CustID") = i
            newRow2("orderDate") = New DateTime(2001, i, j * 2)
            newRow2("OrderAmount") = i * 10 + j * 0.1
            ' Add the row to the Orders table.
            tOrders.Rows.Add(newRow2)
         Next j
      Next i
   End Sub 
End Class 

注解

@No__t-0 向子表显示类似 Web 的链接。The System.Windows.Forms.DataGrid displays Web-like links to child tables. 您可以单击链接以导航到子表。You can click on a link to navigate to the child table. 显示某个子表后,可以单击该标题中的 "后退" 按钮以导航回到父表。When a child table is displayed, a back button appears in the caption that can be clicked to navigate back to the parent table. 父行中的数据显示在标题下方和列标题的上方。The data from the parent rows is displayed below the caption and above the column headers. 可以通过单击 "后退" 按钮右侧的按钮来隐藏父行信息。You can hide the parent row information by clicking the button to the right of the back button.

若要在运行时显示 System.Windows.Forms.DataGrid 中的表,请使用 @no__t 方法将 @no__t 2 和 @no__t 属性设置为有效的数据源。To display a table in the System.Windows.Forms.DataGrid at run time, use the SetDataBinding method to set the DataSource and DataMember properties to a valid data source. 以下数据源有效:The following data sources are valid:

有关 DataSet 类的详细信息,请参阅数据集、数据表和 dataviewFor more information about the DataSet class, see DataSets, DataTables, and DataViews.

您可以创建一个网格,使用户能够编辑数据,但通过使用 @no__t 为数据源的数据源并将 @no__t 1 属性设置为 @no__t,使用户能够编辑数据。You can create a grid that enables users to edit data but prevents them from adding new rows by using a DataView as the data source and setting the AllowNew property to false.

数据源由 BindingManagerBase 对象进一步管理。Data sources are further managed by BindingManagerBase objects. 对于数据源中的每个表,可以从窗体的 @no__t 返回 @no__t 0。For each table in a data source, a BindingManagerBase can be returned from the form's BindingContext. 例如,您可以通过返回关联的 @no__t 0 对象的 @no__t 属性来确定数据源包含的行数。For example, you can determine the number of rows contained by a data source by returning the associated BindingManagerBase object's Count property.

若要验证数据,请使用表示数据及其事件的基础对象。To validate data, use the underlying objects that represent data and their events. 例如,如果数据来自 @no__t @no__t 中的-1,请使用 @no__t 2 和 @no__t 3 事件。For example, if the data comes from a DataTable in a DataSet, use the ColumnChanging and RowChanging events.

备注

由于可以自定义列数(通过添加或删除 GridColumnStylesCollection 的成员)并按列对行进行排序,因此不能保证 RowNumberColumnNumber 属性值对应于 @no__t 中的 @no__t 和 @no__t 索引。Because the number of columns can be customized (by adding or deleting members of the GridColumnStylesCollection) and the rows can be sorted by column, the RowNumber and ColumnNumber property values cannot be guaranteed to correspond to DataRow and DataColumn indexes in a DataTable. 因此,应避免在 Validating 事件中使用这些属性来验证数据。Therefore you should avoid using those properties in the Validating event to validate data.

若要确定选定的单元格,请使用 CurrentCell 属性。To determine which cell is selected, use the CurrentCell property. 通过使用 Item[Int32, Int32] 属性更改任意单元格的值,该属性可以采用单元的行索引和列索引,也可以是单个 DataGridCellChange the value of any cell by using the Item[Int32, Int32] property, which can take either the row and column indexes of the cell, or a single DataGridCell. 监视 @no__t 0 事件,以便在用户选择另一个单元格时进行检测。Monitor the CurrentCellChanged event to detect when the user selects another cell.

若要确定用户单击了哪个控件的部分,请在 @no__t 中使用 @no__t 方法。To determine which part of the control the user clicked, use the HitTest method in the MouseDown event. @No__t-0 方法返回一个 @no__t 的对象,其中包含已单击区域的行和列。The HitTest method returns a DataGrid.HitTestInfo object, which contains the row and column of a clicked area.

若要在运行时管理控件的外观,可以使用多个用于设置颜色和标题特性的属性,包括 CaptionForeColorCaptionBackColorCaptionFont 等等。To manage the appearance of the control at run time, several properties for setting the color and caption attributes are available, including the CaptionForeColor, CaptionBackColor, CaptionFont, and so on.

可以通过创建 @no__t 0 对象并将其添加到 GridTableStylesCollection (可通过 TableStyles 属性访问)来进一步修改所显示网格的外观。The appearance of the displayed grid (or grids) can be further modified by creating DataGridTableStyle objects and adding them to the GridTableStylesCollection, which is accessed through the TableStyles property. 例如,如果 @no__t 设置为包含三个 DataTable 对象的 DataSet,则可以将三个 @no__t 3 个对象添加到集合中,每个表对应一个对象。For example, if the DataSource is set to a DataSet containing three DataTable objects, you can add three DataGridTableStyle objects to the collection, one for each table. 若要将每个 @no__t 0 对象与 DataTable 同步,请将 @no__t 的 @no__t 2 设置为 @no__t 的第4个。To synchronize each DataGridTableStyle object with a DataTable, set the MappingName of the DataGridTableStyle to the TableName of the DataTable. 有关绑定到对象数组的详细信息,请参阅 DataGridTableStyle.MappingName 属性。For more information about binding to an array of objects, see the DataGridTableStyle.MappingName property.

若要创建表的自定义视图,请创建 @no__t 0 或 @no__t 类的实例,并将该对象添加到通过 TableStyles 属性访问的 @no__t。To create a customized view of a table, create an instance of a DataGridTextBoxColumn or DataGridBoolColumn class and add the object to the GridTableStylesCollection accessed through the TableStyles property. 这两个类均从 DataGridColumnStyle 继承。Both classes inherit from DataGridColumnStyle. 对于每个列样式,将 MappingName 设置为要在网格中显示的列的 @no__t。For each column style, set the MappingName to the ColumnName of a column that you want to show in the grid. 若要隐藏某一列,请将其 MappingName 设置为有效 @no__t。To hide a column, set its MappingName to something other than a valid ColumnName.

若要设置列的文本格式,请将 @no__t 的 @no__t 0 属性设置为格式设置类型自定义日期和时间格式字符串中的值之一。To format the text of a column, set the Format property of the DataGridTextBoxColumn to one of the values found in Formatting Types and Custom Date and Time Format Strings.

若要将 DataGrid 绑定到对象的强类型数组,对象类型必须包含公共属性。To bind the DataGrid to a strongly typed array of objects, the object type must contain public properties. 若要创建显示数组的 @no__t 0,请将 @no__t 属性设置为 typename[],其中 typename 替换为对象类型的名称。To create a DataGridTableStyle that displays the array, set the DataGridTableStyle.MappingName property to typename[] where typename is replaced by the name of the object type. 另请注意,MappingName 属性区分大小写;类型名称必须完全匹配。Also note that the MappingName property is case-sensitive; the type name must be matched exactly. 有关示例,请参阅 MappingName 属性。See the MappingName property for an example.

你还可以将 DataGrid 绑定到 @no__t。You can also bind the DataGrid to an ArrayList. @No__t 的一项功能是它可以包含多种类型的对象,但如果列表中的所有项的类型与第一个项的类型相同,则 DataGrid 只能绑定到此类列表。A feature of the ArrayList is that it can contain objects of multiple types, but the DataGrid can only bind to such a list when all items in the list are of the same type as the first item. 这意味着所有对象的类型必须相同,或者必须从列表中的第一项继承同一个类。This means that all objects must either be of the same type, or they must inherit from the same class as the first item in the list. 例如,如果列表中的第一项为 Control,则第二项可以是 TextBox (从 @no__t 继承)。For example, if the first item in a list is a Control, the second item could be a TextBox (which inherits from Control). 另一方面,如果第一项为 TextBox,则第二个对象不能为 ControlIf, on the other hand, the first item is a TextBox, the second object cannot be a Control. 此外,当绑定时,@no__t 0 中必须有项。Further, the ArrayList must have items in it when it is bound. 空的 ArrayList 将导致空网格。An empty ArrayList will result in an empty grid. 此外,@no__t 中的对象必须包含公共属性。In addition, the objects in the ArrayList must contain public properties. 绑定到 ArrayList 时,请将 DataGridTableStyle 的 @no__t 设置为 "ArrayList" (类型名称)。When binding to an ArrayList, set the MappingName of the DataGridTableStyle to "ArrayList" (the type name).

对于每个 DataGridTableStyle,可以设置颜色和标题特性来重写 @no__t 控件的设置。For each DataGridTableStyle, you can set color and caption attributes that override the settings for the System.Windows.Forms.DataGrid control. 但是,如果未设置这些属性,则默认情况下使用控件的设置。However, if those properties are not set, the settings for the control are used by default. @No__t-0 属性可以重写以下属性:The following properties can be overridden by DataGridTableStyle properties:

若要自定义单个列的外观,请将 DataGridColumnStyle 对象添加到 GridColumnStylesCollection,该对象可通过每个 @no__t 的 GridColumnStyles 属性进行访问。To customize the appearance of individual columns, add DataGridColumnStyle objects to the GridColumnStylesCollection, which is accessed through the GridColumnStyles property of each DataGridTableStyle. 若要将每个 DataGridColumnStyle 与 @no__t 中的 DataColumn 同步,请将 @no__t 设置为 @no__t 的第4个。To synchronize each DataGridColumnStyle with a DataColumn in the DataTable, set the MappingName to the ColumnName of a DataColumn. 构造 DataGridColumnStyle 时,还可以设置一个指定列如何显示数据的格式设置字符串。When constructing a DataGridColumnStyle, you can also set a formatting string that specifies how the column displays data. 例如,可以指定列使用短日期格式来显示表中包含的日期。For example, you can specify that the column use a short-date format to display dates contained in the table.

注意

在将 DataGridTableStyle 对象添加到 @no__t 3 之前,始终创建 @no__t 0 个对象并将其添加到 @no__t 1。Always create DataGridColumnStyle objects and add them to the GridColumnStylesCollection before adding DataGridTableStyle objects to the GridTableStylesCollection. 向集合添加具有有效的 MappingName 值的空 DataGridTableStyle 时,将自动为你生成 @no__t 2 个对象。When you add an empty DataGridTableStyle with a valid MappingName value to the collection, DataGridColumnStyle objects are automatically generated for you. 因此,如果尝试将具有重复的 @no__t 1 值的新 @no__t 对象添加到 GridColumnStylesCollection,将引发异常。Consequently, an exception will be thrown if you try to add new DataGridColumnStyle objects with duplicate MappingName values to the GridColumnStylesCollection.

备注

DataGridView 控件取代了 DataGrid 控件并添加了功能;但是,可以选择保留 DataGrid 控件以实现向后兼容并供将来使用。The DataGridView control replaces and adds functionality to the DataGrid control; however, the DataGrid control is retained for both backward compatibility and future use, if you choose. 有关详细信息,请参阅 Windows 窗体 DataGridView 控件与 DataGrid 控件之间的区别For more information, see Differences Between the Windows Forms DataGridView and DataGrid Controls.

构造函数

DataGrid()

初始化 DataGrid 类的新实例。Initializes a new instance of the DataGrid class.

属性

AccessibilityObject

获取分配给该控件的 AccessibleObjectGets the AccessibleObject assigned to the control.

(继承自 Control)
AccessibleDefaultActionDescription

获取或设置控件的默认操作说明以供具有辅助功能的客户端应用程序使用。Gets or sets the default action description of the control for use by accessibility client applications.

(继承自 Control)
AccessibleDescription

获取或设置辅助功能客户端应用程序使用的控件说明。Gets or sets the description of the control used by accessibility client applications.

(继承自 Control)
AccessibleName

获取或设置辅助功能客户端应用程序所使用的控件名称。Gets or sets the name of the control used by accessibility client applications.

(继承自 Control)
AccessibleRole

获取或设置控件的辅助性角色。Gets or sets the accessible role of the control.

(继承自 Control)
AllowDrop

获取或设置一个值,该值指示控件是否可以接受用户拖放到它上面的数据。Gets or sets a value indicating whether the control can accept data that the user drags onto it.

(继承自 Control)
AllowNavigation

获取或设置指示是否允许导航的值。Gets or sets a value indicating whether navigation is allowed.

AllowSorting

获取或设置一个值,该值指示是否可以通过单击列标题对网格进行重新排序。Gets or sets a value indicating whether the grid can be resorted by clicking on a column header.

AlternatingBackColor

获取或设置网格中奇数行的背景色。Gets or sets the background color of odd-numbered rows of the grid.

Anchor

获取或设置控件绑定到的容器的边缘并确定控件如何随其父级一起调整大小。Gets or sets the edges of the container to which a control is bound and determines how a control is resized with its parent.

(继承自 Control)
AutoScrollOffset

获取或设置一个值,该值指示在 ScrollControlIntoView(Control) 中将控件滚动到何处。Gets or sets where this control is scrolled to in ScrollControlIntoView(Control).

(继承自 Control)
AutoSize

此属性与此类无关。This property is not relevant for this class.

(继承自 Control)
BackColor

获取或设置网格中偶数行的背景色。Gets or sets the background color of even-numbered rows of the grid.

BackgroundColor

获取或设置网格中非行区域的颜色。Gets or sets the color of the non-row area of the grid.

BackgroundImage

此成员对于此控件无意义。This member is not meaningful for this control.

BackgroundImageLayout

此成员对于此控件无意义。This member is not meaningful for this control.

BindingContext

获取或设置控件的 BindingContextGets or sets the BindingContext for the control.

(继承自 Control)
BorderStyle

获取或设置网格的边框样式。Gets or sets the grid's border style.

Bottom

获取控件下边缘与其容器的工作区上边缘之间的距离(以像素为单位)。Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.

(继承自 Control)
Bounds

获取或设置控件(包括其非工作区元素)相对于其父控件的大小和位置(以像素为单位)。Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

(继承自 Control)
CanEnableIme

获取一个用以指示是否可以将 ImeMode 属性设置为活动值的值,以启用 IME 支持。Gets a value indicating whether the ImeMode property can be set to an active value, to enable IME support.

(继承自 Control)
CanFocus

获取一个值,该值指示控件是否可以接收焦点。Gets a value indicating whether the control can receive focus.

(继承自 Control)
CanRaiseEvents

确定是否可以在控件上引发事件。Determines if events can be raised on the control.

(继承自 Control)
CanSelect

获取一个值,该值指示是否可以选中控件。Gets a value indicating whether the control can be selected.

(继承自 Control)
CaptionBackColor

获取或设置标题区域的背景色。Gets or sets the background color of the caption area.

CaptionFont

获取或设置网格标题的字体。Gets or sets the font of the grid's caption.

CaptionForeColor

获取或设置标题区域的前景色。Gets or sets the foreground color of the caption area.

CaptionText

获取或设置网格窗口标题的文本。Gets or sets the text of the grid's window caption.

CaptionVisible

获取或设置一个值,该值指示该网格的标题是否可见。Gets or sets a value that indicates whether the grid's caption is visible.

Capture

获取或设置一个值,该值指示控件是否已捕获鼠标。Gets or sets a value indicating whether the control has captured the mouse.

(继承自 Control)
CausesValidation

获取或设置一个值,该值指示控件是否会引起在任何需要在接收焦点时执行验证的控件上执行验证。Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.

(继承自 Control)
ClientRectangle

获取表示控件的工作区的矩形。Gets the rectangle that represents the client area of the control.

(继承自 Control)
ClientSize

获取或设置控件的工作区的高度和宽度。Gets or sets the height and width of the client area of the control.

(继承自 Control)
ColumnHeadersVisible

获得或设置一个指示表的列标题是否可见的值。Gets or sets a value indicating whether the column headers of a table are visible.

CompanyName

获取包含控件的应用程序的公司名称或创建者。Gets the name of the company or creator of the application containing the control.

(继承自 Control)
Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(继承自 Component)
ContainsFocus

获取一个值,该值指示控件或它的一个子控件当前是否有输入焦点。Gets a value indicating whether the control, or one of its child controls, currently has the input focus.

(继承自 Control)
ContextMenu

获取或设置与控件关联的快捷菜单。Gets or sets the shortcut menu associated with the control.

(继承自 Control)
ContextMenuStrip

获取或设置与此控件关联的 ContextMenuStripGets or sets the ContextMenuStrip associated with this control.

(继承自 Control)
Controls

获取包含在控件内的控件的集合。Gets the collection of controls contained within the control.

(继承自 Control)
Created

获取一个值,该值指示控件是否已经创建。Gets a value indicating whether the control has been created.

(继承自 Control)
CreateParams

获取创建控件句柄时所需要的创建参数。Gets the required creation parameters when the control handle is created.

(继承自 Control)
CurrentCell

获取或设置具有焦点的单元格。Gets or sets which cell has the focus. 设计时不可用。Not available at design time.

CurrentRowIndex

获取或设置当前具有焦点的行的索引。Gets or sets index of the row that currently has focus.

Cursor

此成员对于此控件无意义。This member is not meaningful for this control.

DataBindings

为该控件获取数据绑定。Gets the data bindings for the control.

(继承自 Control)
DataMember

获取或设置 DataSource 中的特定列表,DataGrid 控件为该数据源显示网格。Gets or sets the specific list in a DataSource for which the DataGrid control displays a grid.

DataSource

获取或设置网格所显示数据的数据源。Gets or sets the data source that the grid is displaying data for.

DefaultCursor

获取或设置控件的默认光标。Gets or sets the default cursor for the control.

(继承自 Control)
DefaultImeMode

获取控件支持的默认输入法编辑器 (IME) 模式。Gets the default Input Method Editor (IME) mode supported by the control.

(继承自 Control)
DefaultMargin

获取控件之间默认指定的间距(以像素为单位)。Gets the space, in pixels, that is specified by default between controls.

(继承自 Control)
DefaultMaximumSize

获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最大大小。Gets the length and height, in pixels, that is specified as the default maximum size of a control.

(继承自 Control)
DefaultMinimumSize

获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最小大小。Gets the length and height, in pixels, that is specified as the default minimum size of a control.

(继承自 Control)
DefaultPadding

获取控件内容的内部间距(以像素为单位)。Gets the internal spacing, in pixels, of the contents of a control.

(继承自 Control)
DefaultSize

获取控件的默认大小。Gets the default size of the control.

DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(继承自 Component)
DeviceDpi

获取显示当前控件的显示设备的 DPI 值。Gets the DPI value for the display device where the control is currently being displayed.

(继承自 Control)
DisplayRectangle

获取表示控件的显示区域的矩形。Gets the rectangle that represents the display area of the control.

(继承自 Control)
Disposing

获取一个值,该值指示 Control 基类是否在释放进程中。Gets a value indicating whether the base Control class is in the process of disposing.

(继承自 Control)
Dock

获取或设置哪些控件边框停靠到其父控件并确定控件如何随其父级一起调整大小。Gets or sets which control borders are docked to its parent control and determines how a control is resized with its parent.

(继承自 Control)
DoubleBuffered

获取或设置一个值,该值指示此控件是否应使用辅助缓冲区重绘其图面,以减少或避免闪烁。Gets or sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.

(继承自 Control)
Enabled

获取或设置一个值,该值指示控件是否可以对用户交互作出响应。Gets or sets a value indicating whether the control can respond to user interaction.

(继承自 Control)
Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(继承自 Component)
FirstVisibleColumn

获取网格中第一个可见列的索引。Gets the index of the first visible column in a grid.

FlatMode

获取或设置一个值,该值指示网格是否以平面模式显示。Gets or sets a value indicating whether the grid displays in flat mode.

Focused

获取一个值,该值指示控件是否有输入焦点。Gets a value indicating whether the control has input focus.

(继承自 Control)
Font

获取或设置控件显示的文字的字体。Gets or sets the font of the text displayed by the control.

(继承自 Control)
FontHeight

获取或设置控件的字体的高度。Gets or sets the height of the font of the control.

(继承自 Control)
ForeColor

获取或设置 DataGrid 控件的前景色(通常为文本的颜色)属性。Gets or sets the foreground color (typically the color of the text) property of the DataGrid control.

GridLineColor

获取或设置网格线的颜色。Gets or sets the color of the grid lines.

GridLineStyle

获取或设置网格的线型。Gets or sets the line style of the grid.

Handle

获取控件绑定到的窗口句柄。Gets the window handle that the control is bound to.

(继承自 Control)
HasChildren

获取一个值,该值指示控件是否包含一个或多个子控件。Gets a value indicating whether the control contains one or more child controls.

(继承自 Control)
HeaderBackColor

获取或设置所有行标题和列标题的背景色。Gets or sets the background color of all row and column headers.

HeaderFont

获取或设置列标题所用的字体。Gets or sets the font used for column headers.

HeaderForeColor

获取或设置标题的前景色。Gets or sets the foreground color of headers.

Height

获取或设置控件的高度。Gets or sets the height of the control.

(继承自 Control)
HorizScrollBar

获取网格的水平滚动条。Gets the horizontal scroll bar for the grid.

ImeMode

获取或设置控件的输入法编辑器 (IME) 模式。Gets or sets the Input Method Editor (IME) mode of the control.

(继承自 Control)
ImeModeBase

获取或设置控件的 IME 模式。Gets or sets the IME mode of a control.

(继承自 Control)
InvokeRequired

获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用 Invoke 方法,因为调用方位于创建控件所在的线程以外的线程中。Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.

(继承自 Control)
IsAccessible

获取或设置一个值,该值指示控件对辅助功能应用程序是否可见。Gets or sets a value indicating whether the control is visible to accessibility applications.

(继承自 Control)
IsDisposed

获取一个值,该值指示控件是否已经被释放。Gets a value indicating whether the control has been disposed of.

(继承自 Control)
IsHandleCreated

获取一个值,该值指示控件是否有与它关联的句柄。Gets a value indicating whether the control has a handle associated with it.

(继承自 Control)
IsMirrored

获取一个值,该值指示此控件是否为镜像控件。Gets a value indicating whether the control is mirrored.

(继承自 Control)
Item[DataGridCell]

获取或设置指定的 DataGridCell 的值。Gets or sets the value of a specified DataGridCell.

Item[Int32, Int32]

获取或设置位于指定行和列的单元格的值。Gets or sets the value of the cell at the specified the row and column.

LayoutEngine

获取控件的布局引擎的缓存实例。Gets a cached instance of the control's layout engine.

(继承自 Control)
Left

获取或设置控件左边缘与其容器的工作区左边缘之间的距离(以像素为单位)。Gets or sets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.

(继承自 Control)
LinkColor

获取或设置单击即可定位到子表的文本的颜色。Gets or sets the color of the text that you can click to navigate to a child table.

LinkHoverColor

此成员对于此控件无意义。This member is not meaningful for this control.

ListManager

获取该 CurrencyManager 控件的 DataGridGets the CurrencyManager for this DataGrid control.

Location

获取或设置该控件的左上角相对于其容器的左上角的坐标。Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

(继承自 Control)
Margin

获取或设置控件之间的空间。Gets or sets the space between controls.

(继承自 Control)
MaximumSize

获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的上限。Gets or sets the size that is the upper limit that GetPreferredSize(Size) can specify.

(继承自 Control)
MinimumSize

获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的下限。Gets or sets the size that is the lower limit that GetPreferredSize(Size) can specify.

(继承自 Control)
Name

获取或设置控件的名称。Gets or sets the name of the control.

(继承自 Control)
Padding

获取或设置控件内的空白。Gets or sets padding within the control.

(继承自 Control)
Parent

获取或设置控件的父容器。Gets or sets the parent container of the control.

(继承自 Control)
ParentRowsBackColor

获取或设置父行的背景色。Gets or sets the background color of parent rows.

ParentRowsForeColor

获取或设置父行的前景色。Gets or sets the foreground color of parent rows.

ParentRowsLabelStyle

获取或设置父行标签的显示方式。Gets or sets the way parent row labels are displayed.

ParentRowsVisible

获取或设置一个值,该值指示表的父行是否可见。Gets or sets a value indicating whether the parent rows of a table are visible.

PreferredColumnWidth

获取或设置网格列的默认宽度(以像素为单位)。Gets or sets the default width of the grid columns in pixels.

PreferredRowHeight

获取或设置 DataGrid 控件的首选行高度。Gets or sets the preferred row height for the DataGrid control.

PreferredSize

获取可以容纳控件的矩形区域的大小。Gets the size of a rectangular area into which the control can fit.

(继承自 Control)
ProductName

获取包含控件的程序集的产品名称。Gets the product name of the assembly containing the control.

(继承自 Control)
ProductVersion

获取包含控件的程序集的版本。Gets the version of the assembly containing the control.

(继承自 Control)
ReadOnly

获取或设置一个指示网格是否处于只读模式的值。Gets or sets a value indicating whether the grid is in read-only mode.

RecreatingHandle

获取一个值,该值指示控件当前是否在重新创建其句柄。Gets a value indicating whether the control is currently re-creating its handle.

(继承自 Control)
Region

获取或设置与控件关联的窗口区域。Gets or sets the window region associated with the control.

(继承自 Control)
RenderRightToLeft

此属性现已过时。This property is now obsolete.

(继承自 Control)
ResizeRedraw

获取或设置一个值,该值指示控件在调整大小时是否重绘自己。Gets or sets a value indicating whether the control redraws itself when resized.

(继承自 Control)
Right

获取控件右边缘与其容器的工作区左边缘之间的距离(以像素为单位)。Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area.

(继承自 Control)
RightToLeft

获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

(继承自 Control)
RowHeadersVisible

获取或设置一个值,该值指定行标题是否可见。Gets or sets a value that specifies whether row headers are visible.

RowHeaderWidth

获取或设置行标题宽度。Gets or sets the width of row headers.

ScaleChildren

获取一个值,该值确定子控件的缩放。Gets a value that determines the scaling of child controls.

(继承自 Control)
SelectionBackColor

获取或设置选定行的背景色。Gets or sets the background color of selected rows.

SelectionForeColor

获取或设置选定行的前景色。Gets or set the foreground color of selected rows.

ShowFocusCues

获取一个值,该值指示控件是否应显示聚焦框。Gets a value indicating whether the control should display focus rectangles.

(继承自 Control)
ShowKeyboardCues

获取一个值,该值指示用户界面是否处于适当的状态以显示或隐藏键盘快捷键。Gets a value indicating whether the user interface is in the appropriate state to show or hide keyboard accelerators.

(继承自 Control)
Site

获取或设置控件的站点。Gets or sets the site of the control.

Size

获取或设置控件的高度和宽度。Gets or sets the height and width of the control.

(继承自 Control)
TabIndex

获取或设置控件在其容器内的 Tab 键顺序。Gets or sets the tab order of the control within its container.

(继承自 Control)
TableStyles

获取网格的 DataGridTableStyle 对象的集合。Gets the collection of DataGridTableStyle objects for the grid.

TabStop

获取或设置一个值,该值指示用户能否使用 Tab 键将焦点放到该控件上。Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.

(继承自 Control)
Tag

获取或设置包含有关控件的数据的对象。Gets or sets the object that contains data about the control.

(继承自 Control)
Text

此成员对于此控件无意义。This member is not meaningful for this control.

Top

获取或设置控件上边缘与其容器的工作区上边缘之间的距离(以像素为单位)。Gets or sets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.

(继承自 Control)
TopLevelControl

获取没有另一个 Windows 窗体控件作为其父级的父控件。Gets the parent control that is not parented by another Windows Forms control. 通常,这是控件所在的最外面的 FormTypically, this is the outermost Form that the control is contained in.

(继承自 Control)
UseWaitCursor

获取或设置一个值,该值指示是否将等待光标用于当前控件以及所有子控件。Gets or sets a value indicating whether to use the wait cursor for the current control and all child controls.

(继承自 Control)
VertScrollBar

获取控件的垂直滚动条。Gets the vertical scroll bar of the control.

Visible

获取或设置一个值,该值指示是否显示该控件及其所有子控件。Gets or sets a value indicating whether the control and all its child controls are displayed.

(继承自 Control)
VisibleColumnCount

获取可见列的数目。Gets the number of visible columns.

VisibleRowCount

获取可见行的数目。Gets the number of rows visible.

Width

获取或设置控件的宽度。Gets or sets the width of the control.

(继承自 Control)
WindowTarget

此属性与此类无关。This property is not relevant for this class.

(继承自 Control)

方法

AccessibilityNotifyClients(AccessibleEvents, Int32)

就指定子控件的指定 AccessibleEvents 通知辅助功能客户端应用程序。Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control.

(继承自 Control)
AccessibilityNotifyClients(AccessibleEvents, Int32, Int32)

就指定子控件的指定 AccessibleEvents 通知辅助功能客户端应用程序。Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control .

(继承自 Control)
BeginEdit(DataGridColumnStyle, Int32)

尝试将网格置于允许编辑的状态。Attempts to put the grid into a state where editing is allowed.

BeginInit()

开始初始化在窗体上使用或由另一个组件使用的 DataGridBegins the initialization of a DataGrid that is used on a form or used by another component. 初始化发生在运行时。The initialization occurs at run time.

BeginInvoke(Delegate)

在创建控件的基础句柄所在线程上异步执行指定委托。Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

(继承自 Control)
BeginInvoke(Delegate, Object[])

在创建控件的基础句柄所在线程上,用指定的参数异步执行指定委托。Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.

(继承自 Control)
BringToFront()

将控件带到 Z 顺序的前面。Brings the control to the front of the z-order.

(继承自 Control)
CancelEditing()

取消当前编辑操作并回滚所有更改。Cancels the current edit operation and rolls back all changes.

Collapse(Int32)

折叠对于所有行存在的子关系或折叠指定行的子关系。Collapses child relations, if any exist for all rows, or for a specified row.

ColumnStartedEditing(Control)

当用户开始使用指定控件编辑列时通知 DataGrid 控件。Informs the DataGrid control when the user begins to edit a column using the specified control.

ColumnStartedEditing(Rectangle)

当用户开始在指定位置编辑列时通知 DataGrid 控件。Informs the DataGrid control when the user begins to edit the column at the specified location.

Contains(Control)

检索一个值,该值指示指定控件是否为一个控件的子控件。Retrieves a value indicating whether the specified control is a child of the control.

(继承自 Control)
CreateAccessibilityInstance()

为此控件构造辅助功能对象的新实例。Constructs a new instance of the accessibility object for this control.

CreateControl()

强制创建可见控件,包括创建句柄和任何可见子控件。Forces the creation of the visible control, including the creation of the handle and any visible child controls.

(继承自 Control)
CreateControlsInstance()

为控件创建控件集合的新实例。Creates a new instance of the control collection for the control.

(继承自 Control)
CreateGraphics()

为控件创建 GraphicsCreates the Graphics for the control.

(继承自 Control)
CreateGridColumn(PropertyDescriptor)

使用指定的 DataGridColumnStyle 创建一个新的 PropertyDescriptorCreates a new DataGridColumnStyle with the specified PropertyDescriptor.

CreateGridColumn(PropertyDescriptor, Boolean)

使用指定的 DataGridColumnStyle 创建一个 PropertyDescriptorCreates a DataGridColumnStyle using the specified PropertyDescriptor.

CreateHandle()

为该控件创建句柄。Creates a handle for the control.

(继承自 Control)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
DefWndProc(Message)

向默认窗口过程发送指定消息。Sends the specified message to the default window procedure.

(继承自 Control)
DestroyHandle()

毁坏与该控件关联的句柄。Destroys the handle associated with the control.

(继承自 Control)
Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(继承自 Component)
Dispose(Boolean)

处置由 DataGrid 占用的资源(内存除外)。Disposes of the resources (other than memory) used by the DataGrid.

DoDragDrop(Object, DragDropEffects)

开始拖放操作。Begins a drag-and-drop operation.

(继承自 Control)
DrawToBitmap(Bitmap, Rectangle)

支持对指定位图的呈现。Supports rendering to the specified bitmap.

(继承自 Control)
EndEdit(DataGridColumnStyle, Int32, Boolean)

请求结束 DataGrid 控件中进行的编辑操作。Requests an end to an edit operation taking place on the DataGrid control.

EndInit()

结束在窗体上使用或由另一个组件使用的 DataGrid 的初始化。Ends the initialization of a DataGrid that is used on a form or used by another component. 初始化发生在运行时。The initialization occurs at run time.

EndInvoke(IAsyncResult)

检索由传递的 IAsyncResult 表示的异步操作的返回值。Retrieves the return value of the asynchronous operation represented by the IAsyncResult passed.

(继承自 Control)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Expand(Int32)

显示所有行或特定行的子关系(如果存在)。Displays child relations, if any exist, for all rows or a specific row.

FindForm()

检索控件所在的窗体。Retrieves the form that the control is on.

(继承自 Control)
Focus()

为控件设置输入焦点。Sets input focus to the control.

(继承自 Control)
GetAccessibilityObjectById(Int32)

检索指定的 AccessibleObjectRetrieves the specified AccessibleObject.

(继承自 Control)
GetAutoSizeMode()

检索一个值,该值指示当启用控件的 AutoSize 属性时控件的行为方式。Retrieves a value indicating how a control will behave when its AutoSize property is enabled.

(继承自 Control)
GetCellBounds(DataGridCell)

获取 Rectangle 所指定的单元格的 DataGridCellGets the Rectangle of the cell specified by DataGridCell.

GetCellBounds(Int32, Int32)

获取由行号和列号指定的单元格的 RectangleGets the Rectangle of the cell specified by row and column number.

GetChildAtPoint(Point)

检索位于指定坐标处的子控件。Retrieves the child control that is located at the specified coordinates.

(继承自 Control)
GetChildAtPoint(Point, GetChildAtPointSkip)

检索位于指定坐标的子控件,并且指定是否忽略特定类型的子控件。Retrieves the child control that is located at the specified coordinates, specifying whether to ignore child controls of a certain type.

(继承自 Control)
GetContainerControl()

沿着控件的父控件链向上,返回下一个 ContainerControlReturns the next ContainerControl up the control's chain of parent controls.

(继承自 Control)
GetCurrentCellBounds()

获取一个 Rectangle,它指定选定单元格的四个角。Gets a Rectangle that specifies the four corners of the selected cell.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetNextControl(Control, Boolean)

按照子控件的 Tab 键顺序向前或向后检索下一个控件。Retrieves the next control forward or back in the tab order of child controls.

(继承自 Control)
GetOutputTextDelimiter()

当行内容被复制到剪贴板时,获取作为列间的分隔符的字符串。Gets the string that is the delimiter between columns when row contents are copied to the Clipboard.

GetPreferredSize(Size)

检索适合控件的矩形区域的大小。Retrieves the size of a rectangular area into which a control can be fitted.

(继承自 Control)
GetScaledBounds(Rectangle, SizeF, BoundsSpecified)

检索缩放控件时的边界。Retrieves the bounds within which the control is scaled.

(继承自 Control)
GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(继承自 Component)
GetStyle(ControlStyles)

为控件检索指定控件样式位的值。Retrieves the value of the specified control style bit for the control.

(继承自 Control)
GetTopLevel()

确定控件是否是顶级控件。Determines if the control is a top-level control.

(继承自 Control)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GridHScrolled(Object, ScrollEventArgs)

侦听水平滚动条的滚动事件。Listens for the scroll event of the horizontal scroll bar.

GridVScrolled(Object, ScrollEventArgs)

侦听垂直滚动条的滚动事件。Listens for the scroll event of the vertical scroll bar.

Hide()

对用户隐藏控件。Conceals the control from the user.

(继承自 Control)
HitTest(Int32, Int32)

使用传递给方法的 x 和 y 坐标获取信息(如网格上被单击点的行号和列号)。Gets information, such as row and column number of a clicked point on the grid, using the x and y coordinate passed to the method.

HitTest(Point)

获取有关使用特定 Point 的网格的信息(如网格中被单击点的行号和列号)。Gets information, such as row and column number of a clicked point on the grid, about the grid using a specific Point.

InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
InitLayout()

在将控件添加到另一个容器之后调用。Called after the control has been added to another container.

(继承自 Control)
Invalidate()

使控件的整个图面无效并导致重绘控件。Invalidates the entire surface of the control and causes the control to be redrawn.

(继承自 Control)
Invalidate(Boolean)

使控件的特定区域无效并向控件发送绘制消息。Invalidates a specific region of the control and causes a paint message to be sent to the control. 还可以使分配给该控件的子控件无效。Optionally, invalidates the child controls assigned to the control.

(继承自 Control)
Invalidate(Rectangle)

使控件的指定区域无效(将其添加到控件的更新区域,下次绘制操作时将重新绘制更新区域),并向控件发送绘制消息。Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

(继承自 Control)
Invalidate(Rectangle, Boolean)

使控件的指定区域无效(将其添加到控件的更新区域,下次绘制操作时将重新绘制更新区域),并向控件发送绘制消息。Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. 还可以使分配给该控件的子控件无效。Optionally, invalidates the child controls assigned to the control.

(继承自 Control)
Invalidate(Region)

使控件的指定区域无效(将其添加到控件的更新区域,下次绘制操作时将重新绘制更新区域),并向控件发送绘制消息。Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

(继承自 Control)
Invalidate(Region, Boolean)

使控件的指定区域无效(将其添加到控件的更新区域,下次绘制操作时将重新绘制更新区域),并向控件发送绘制消息。Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. 还可以使分配给该控件的子控件无效。Optionally, invalidates the child controls assigned to the control.

(继承自 Control)
Invoke(Delegate)

在拥有此控件的基础窗口句柄的线程上执行指定的委托。Executes the specified delegate on the thread that owns the control's underlying window handle.

(继承自 Control)
Invoke(Delegate, Object[])

在拥有控件的基础窗口句柄的线程上,用指定的参数列表执行指定委托。Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.

(继承自 Control)
InvokeGotFocus(Control, EventArgs)

为指定的控件引发 GotFocus 事件。Raises the GotFocus event for the specified control.

(继承自 Control)
InvokeLostFocus(Control, EventArgs)

为指定的控件引发 LostFocus 事件。Raises the LostFocus event for the specified control.

(继承自 Control)
InvokeOnClick(Control, EventArgs)

为指定的控件引发 Click 事件。Raises the Click event for the specified control.

(继承自 Control)
InvokePaint(Control, PaintEventArgs)

为指定的控件引发 Paint 事件。Raises the Paint event for the specified control.

(继承自 Control)
InvokePaintBackground(Control, PaintEventArgs)

为指定的控件引发 PaintBackground 事件。Raises the PaintBackground event for the specified control.

(继承自 Control)
IsExpanded(Int32)

获取一个值,该值指示指定行的节点是展开还是折叠的。Gets a value that indicates whether the node of a specified row is expanded or collapsed.

IsInputChar(Char)

确定一个字符是否是控件可识别的输入字符。Determines if a character is an input character that the control recognizes.

(继承自 Control)
IsInputKey(Keys)

确定指定的键是常规输入键还是需要预处理的特殊键。Determines whether the specified key is a regular input key or a special key that requires preprocessing.

(继承自 Control)
IsSelected(Int32)

获取一个值,该值指示指定行是否被选定。Gets a value indicating whether a specified row is selected.

LogicalToDeviceUnits(Int32)

将逻辑 DPI 值转换为它的等效 DeviceUnit DPI 值。Converts a Logical DPI value to its equivalent DeviceUnit DPI value.

(继承自 Control)
LogicalToDeviceUnits(Size)

通过为当前 DPI 缩放小大并将其向下舍入为最接近的宽度和高度的整数值,将大小从逻辑单位转换为设备单位。Transforms a size from logical to device units by scaling it for the current DPI and rounding down to the nearest integer value for width and height.

(继承自 Control)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
NavigateBack()

向后定位到网格中以前显示的表。Navigates back to the table previously displayed in the grid.

NavigateTo(Int32, String)

定位到由行和关系名指定的表。Navigates to the table specified by row and relation name.

NotifyInvalidate(Rectangle)

引发 Invalidated 事件,其中带有要使之无效的控件的指定区域。Raises the Invalidated event with a specified region of the control to invalidate.

(继承自 Control)
OnAllowNavigationChanged(EventArgs)

引发 AllowNavigationChanged 事件。Raises the AllowNavigationChanged event.

OnAutoSizeChanged(EventArgs)

引发 AutoSizeChanged 事件。Raises the AutoSizeChanged event.

(继承自 Control)
OnBackButtonClicked(Object, EventArgs)

侦听标题中的后退按钮被单击事件。Listens for the caption's back button clicked event.

OnBackColorChanged(EventArgs)

引发 BackColorChanged 事件。Raises the BackColorChanged event.

OnBackgroundColorChanged(EventArgs)

引发 BackgroundColorChanged 事件。Raises the BackgroundColorChanged event.

OnBackgroundImageChanged(EventArgs)

引发 BackgroundImageChanged 事件。Raises the BackgroundImageChanged event.

(继承自 Control)
OnBackgroundImageLayoutChanged(EventArgs)

引发 BackgroundImageLayoutChanged 事件。Raises the BackgroundImageLayoutChanged event.

(继承自 Control)
OnBindingContextChanged(EventArgs)

引发 BindingContextChanged 事件。Raises the BindingContextChanged event.

OnBorderStyleChanged(EventArgs)

引发 BorderStyleChanged 事件。Raises the BorderStyleChanged event.

OnCaptionVisibleChanged(EventArgs)

引发 CaptionVisibleChanged 事件。Raises the CaptionVisibleChanged event.

OnCausesValidationChanged(EventArgs)

引发 CausesValidationChanged 事件。Raises the CausesValidationChanged event.

(继承自 Control)
OnChangeUICues(UICuesEventArgs)

引发 ChangeUICues 事件。Raises the ChangeUICues event.

(继承自 Control)
OnClick(EventArgs)

引发 Click 事件。Raises the Click event.

(继承自 Control)
OnClientSizeChanged(EventArgs)

引发 ClientSizeChanged 事件。Raises the ClientSizeChanged event.

(继承自 Control)
OnContextMenuChanged(EventArgs)

引发 ContextMenuChanged 事件。Raises the ContextMenuChanged event.

(继承自 Control)
OnContextMenuStripChanged(EventArgs)

引发 ContextMenuStripChanged 事件。Raises the ContextMenuStripChanged event.

(继承自 Control)
OnControlAdded(ControlEventArgs)

引发 ControlAdded 事件。Raises the ControlAdded event.

(继承自 Control)
OnControlRemoved(ControlEventArgs)

引发 ControlRemoved 事件。Raises the ControlRemoved event.

(继承自 Control)
OnCreateControl()

引发 CreateControl() 方法。Raises the CreateControl() method.

(继承自 Control)
OnCurrentCellChanged(EventArgs)

引发 CurrentCellChanged 事件。Raises the CurrentCellChanged event.

OnCursorChanged(EventArgs)

引发 CursorChanged 事件。Raises the CursorChanged event.

(继承自 Control)
OnDataSourceChanged(EventArgs)

引发 DataSourceChanged 事件。Raises the DataSourceChanged event.

OnDockChanged(EventArgs)

引发 DockChanged 事件。Raises the DockChanged event.

(继承自 Control)
OnDoubleClick(EventArgs)

引发 DoubleClick 事件。Raises the DoubleClick event.

(继承自 Control)
OnDpiChangedAfterParent(EventArgs)

引发 DpiChangedAfterParent 事件。Raises the DpiChangedAfterParent event.

(继承自 Control)
OnDpiChangedBeforeParent(EventArgs)

引发 DpiChangedBeforeParent 事件。Raises the DpiChangedBeforeParent event.

(继承自 Control)
OnDragDrop(DragEventArgs)

引发 DragDrop 事件。Raises the DragDrop event.

(继承自 Control)
OnDragEnter(DragEventArgs)

引发 DragEnter 事件。Raises the DragEnter event.

(继承自 Control)
OnDragLeave(EventArgs)

引发 DragLeave 事件。Raises the DragLeave event.

(继承自 Control)
OnDragOver(DragEventArgs)

引发 DragOver 事件。Raises the DragOver event.

(继承自 Control)
OnEnabledChanged(EventArgs)

引发 EnabledChanged 事件。Raises the EnabledChanged event.

(继承自 Control)
OnEnter(EventArgs)

引发 Enter 事件。Raises the Enter event.

OnFlatModeChanged(EventArgs)

引发 FlatModeChanged 事件。Raises the FlatModeChanged event.

OnFontChanged(EventArgs)

引发 FontChanged 事件。Raises the FontChanged event.

OnForeColorChanged(EventArgs)

引发 ForeColorChanged 事件。Raises the ForeColorChanged event.

OnGiveFeedback(GiveFeedbackEventArgs)

引发 GiveFeedback 事件。Raises the GiveFeedback event.

(继承自 Control)
OnGotFocus(EventArgs)

引发 GotFocus 事件。Raises the GotFocus event.

(继承自 Control)
OnHandleCreated(EventArgs)

引发 CreateHandle() 事件。Raises the CreateHandle() event.

OnHandleDestroyed(EventArgs)

引发 DestroyHandle() 事件。Raises the DestroyHandle() event.

OnHelpRequested(HelpEventArgs)

引发 HelpRequested 事件。Raises the HelpRequested event.

(继承自 Control)
OnImeModeChanged(EventArgs)

引发 ImeModeChanged 事件。Raises the ImeModeChanged event.

(继承自 Control)
OnInvalidated(InvalidateEventArgs)

引发 Invalidated 事件。Raises the Invalidated event.

(继承自 Control)
OnKeyDown(KeyEventArgs)

引发 KeyDown 事件。Raises the KeyDown event.

OnKeyPress(KeyPressEventArgs)

引发 KeyPress 事件。Raises the KeyPress event.

OnKeyUp(KeyEventArgs)

引发 KeyUp 事件。Raises the KeyUp event.

(继承自 Control)
OnLayout(LayoutEventArgs)

引发重新定位控件并更新滚动条的 Layout 事件。Raises the Layout event, which repositions controls and updates scroll bars.

OnLeave(EventArgs)

引发 Leave 事件。Raises the Leave event.

OnLocationChanged(EventArgs)

引发 LocationChanged 事件。Raises the LocationChanged event.

(继承自 Control)
OnLostFocus(EventArgs)

引发 LostFocus 事件。Raises the LostFocus event.

(继承自 Control)
OnMarginChanged(EventArgs)

引发 MarginChanged 事件。Raises the MarginChanged event.

(继承自 Control)
OnMouseCaptureChanged(EventArgs)

引发 MouseCaptureChanged 事件。Raises the MouseCaptureChanged event.

(继承自 Control)
OnMouseClick(MouseEventArgs)

引发 MouseClick 事件。Raises the MouseClick event.

(继承自 Control)
OnMouseDoubleClick(MouseEventArgs)

引发 MouseDoubleClick 事件。Raises the MouseDoubleClick event.

(继承自 Control)
OnMouseDown(MouseEventArgs)

引发 MouseDown 事件。Raises the MouseDown event.

OnMouseEnter(EventArgs)

引发 MouseEnter 事件。Raises the MouseEnter event.

(继承自 Control)
OnMouseHover(EventArgs)

引发 MouseHover 事件。Raises the MouseHover event.

(继承自 Control)
OnMouseLeave(EventArgs)

创建 MouseLeave 事件。Creates the MouseLeave event.

OnMouseMove(MouseEventArgs)

引发 MouseMove 事件。Raises the MouseMove event.

OnMouseUp(MouseEventArgs)

引发 MouseUp 事件。Raises the MouseUp event.

OnMouseWheel(MouseEventArgs)

引发 MouseWheel 事件。Raises the MouseWheel event.

OnMove(EventArgs)

引发 Move 事件。Raises the Move event.

(继承自 Control)
OnNavigate(NavigateEventArgs)

引发 Navigate 事件。Raises the Navigate event.

OnNotifyMessage(Message)

向控件通知 Windows 消息。Notifies the control of Windows messages.

(继承自 Control)
OnPaddingChanged(EventArgs)

引发 PaddingChanged 事件。Raises the PaddingChanged event.

(继承自 Control)
OnPaint(PaintEventArgs)

引发 Paint 事件。Raises the Paint event.

OnPaintBackground(PaintEventArgs)

重写 OnPaintBackground(PaintEventArgs) 以防止绘制 DataGrid 控件的背景。Overrides OnPaintBackground(PaintEventArgs) to prevent painting the background of the DataGrid control.

OnParentBackColorChanged(EventArgs)

当控件容器的 BackColorChanged 属性值更改时,将引发 BackColor 事件。Raises the BackColorChanged event when the BackColor property value of the control's container changes.

(继承自 Control)
OnParentBackgroundImageChanged(EventArgs)

当控件容器的 BackgroundImageChanged 属性值更改时,将引发 BackgroundImage 事件。Raises the BackgroundImageChanged event when the BackgroundImage property value of the control's container changes.

(继承自 Control)
OnParentBindingContextChanged(EventArgs)

当控件容器的 BindingContextChanged 属性值更改时,将引发 BindingContext 事件。Raises the BindingContextChanged event when the BindingContext property value of the control's container changes.

(继承自 Control)
OnParentChanged(EventArgs)

引发 ParentChanged 事件。Raises the ParentChanged event.

(继承自 Control)
OnParentCursorChanged(EventArgs)

引发 CursorChanged 事件。Raises the CursorChanged event.

(继承自 Control)
OnParentEnabledChanged(EventArgs)

当控件容器的 EnabledChanged 属性值更改时,将引发 Enabled 事件。Raises the EnabledChanged event when the Enabled property value of the control's container changes.

(继承自 Control)
OnParentFontChanged(EventArgs)

当控件容器的 FontChanged 属性值更改时,将引发 Font 事件。Raises the FontChanged event when the Font property value of the control's container changes.

(继承自 Control)
OnParentForeColorChanged(EventArgs)

当控件容器的 ForeColorChanged 属性值更改时,将引发 ForeColor 事件。Raises the ForeColorChanged event when the ForeColor property value of the control's container changes.

(继承自 Control)
OnParentRightToLeftChanged(EventArgs)

当控件容器的 RightToLeftChanged 属性值更改时,将引发 RightToLeft 事件。Raises the RightToLeftChanged event when the RightToLeft property value of the control's container changes.

(继承自 Control)
OnParentRowsLabelStyleChanged(EventArgs)

引发 ParentRowsLabelStyleChanged 事件。Raises the ParentRowsLabelStyleChanged event.

OnParentRowsVisibleChanged(EventArgs)

引发 ParentRowsVisibleChanged 事件。Raises the ParentRowsVisibleChanged event.

OnParentVisibleChanged(EventArgs)

当控件容器的 VisibleChanged 属性值更改时,将引发 Visible 事件。Raises the VisibleChanged event when the Visible property value of the control's container changes.

(继承自 Control)
OnPreviewKeyDown(PreviewKeyDownEventArgs)

引发 PreviewKeyDown 事件。Raises the PreviewKeyDown event.

(继承自 Control)
OnPrint(PaintEventArgs)

引发 Paint 事件。Raises the Paint event.

(继承自 Control)
OnQueryContinueDrag(QueryContinueDragEventArgs)

引发 QueryContinueDrag 事件。Raises the QueryContinueDrag event.

(继承自 Control)
OnReadOnlyChanged(EventArgs)

引发 ReadOnlyChanged 事件。Raises the ReadOnlyChanged event.

OnRegionChanged(EventArgs)

引发 RegionChanged 事件。Raises the RegionChanged event.

(继承自 Control)
OnResize(EventArgs)

引发 Resize 事件。Raises the Resize event.

OnRightToLeftChanged(EventArgs)

引发 RightToLeftChanged 事件。Raises the RightToLeftChanged event.

(继承自 Control)
OnRowHeaderClick(EventArgs)

引发 RowHeaderClick 事件。Raises the RowHeaderClick event.

OnScroll(EventArgs)

引发 Scroll 事件。Raises the Scroll event.

OnShowParentDetailsButtonClicked(Object, EventArgs)

引发 ShowParentDetailsButtonClick 事件。Raises the ShowParentDetailsButtonClick event.

OnSizeChanged(EventArgs)

引发 SizeChanged 事件。Raises the SizeChanged event.

(继承自 Control)
OnStyleChanged(EventArgs)

引发 StyleChanged 事件。Raises the StyleChanged event.

(继承自 Control)
OnSystemColorsChanged(EventArgs)

引发 SystemColorsChanged 事件。Raises the SystemColorsChanged event.

(继承自 Control)
OnTabIndexChanged(EventArgs)

引发 TabIndexChanged 事件。Raises the TabIndexChanged event.

(继承自 Control)
OnTabStopChanged(EventArgs)

引发 TabStopChanged 事件。Raises the TabStopChanged event.

(继承自 Control)
OnTextChanged(EventArgs)

引发 TextChanged 事件。Raises the TextChanged event.

(继承自 Control)
OnValidated(EventArgs)

引发 Validated 事件。Raises the Validated event.

(继承自 Control)
OnValidating(CancelEventArgs)

引发 Validating 事件。Raises the Validating event.

(继承自 Control)
OnVisibleChanged(EventArgs)

引发 VisibleChanged 事件。Raises the VisibleChanged event.

(继承自 Control)
PerformLayout()

强制控件将布局逻辑应用于其所有子控件。Forces the control to apply layout logic to all its child controls.

(继承自 Control)
PerformLayout(Control, String)

强制控件将布局逻辑应用于其所有子控件。Forces the control to apply layout logic to all its child controls.

(继承自 Control)
PointToClient(Point)

将指定屏幕点的位置计算成工作区坐标。Computes the location of the specified screen point into client coordinates.

(继承自 Control)
PointToScreen(Point)

将指定工作区点的位置计算成屏幕坐标。Computes the location of the specified client point into screen coordinates.

(继承自 Control)
PreProcessControlMessage(Message)

在调度键盘或输入消息之前,在消息循环内对它们进行预处理。Preprocesses keyboard or input messages within the message loop before they are dispatched.

(继承自 Control)
PreProcessMessage(Message)

在调度键盘或输入消息之前,在消息循环内对它们进行预处理。Preprocesses keyboard or input messages within the message loop before they are dispatched.

(继承自 Control)
ProcessCmdKey(Message, Keys)

处理命令键。Processes a command key.

(继承自 Control)
ProcessDialogChar(Char)

处理对话框字符。Processes a dialog character.

(继承自 Control)
ProcessDialogKey(Keys)

获取或设置一个值,该值指示是否应进一步处理某键。Gets or sets a value that indicates whether a key should be processed further.

ProcessGridKey(KeyEventArgs)

处理键进行网格导航。Processes keys for grid navigation.

ProcessKeyEventArgs(Message)

处理键消息并生成适当的控件事件。Processes a key message and generates the appropriate control events.

(继承自 Control)
ProcessKeyMessage(Message)

处理键盘消息。Processes a keyboard message.

(继承自 Control)
ProcessKeyPreview(Message)

预览键盘消息,并返回指示该键是否已使用的值。Previews a keyboard message and returns a value indicating if the key was consumed.

ProcessMnemonic(Char)

处理助记键字符。Processes a mnemonic character.

(继承自 Control)
ProcessTabKey(Keys)

获取一个值,该值指示是否应处理 Tab 键。Gets a value indicating whether the Tab key should be processed.

RaiseDragEvent(Object, DragEventArgs)

引发适当的拖动事件。Raises the appropriate drag event.

(继承自 Control)
RaiseKeyEvent(Object, KeyEventArgs)

引发适当的键事件。Raises the appropriate key event.

(继承自 Control)
RaiseMouseEvent(Object, MouseEventArgs)

引发适当的鼠标事件。Raises the appropriate mouse event.

(继承自 Control)
RaisePaintEvent(Object, PaintEventArgs)

引发适当的绘画事件。Raises the appropriate paint event.

(继承自 Control)
RecreateHandle()

强制为控件重新创建句柄。Forces the re-creation of the handle for the control.

(继承自 Control)
RectangleToClient(Rectangle)

计算指定屏幕矩形的大小和位置(以工作区坐标表示)。Computes the size and location of the specified screen rectangle in client coordinates.

(继承自 Control)
RectangleToScreen(Rectangle)

计算指定工作区矩形的大小和位置(以屏幕坐标表示)。Computes the size and location of the specified client rectangle in screen coordinates.

(继承自 Control)
Refresh()

强制控件使其工作区无效并立即重绘自己和任何子控件。Forces the control to invalidate its client area and immediately redraw itself and any child controls.

(继承自 Control)
RescaleConstantsForDpi(Int32, Int32)

发生 DPI 更改时,提供用于重新缩放控件的常数。Provides constants for rescaling the control when a DPI change occurs.

(继承自 Control)
ResetAlternatingBackColor()

AlternatingBackColor 属性重置为其默认颜色。Resets the AlternatingBackColor property to its default color.

ResetBackColor()

BackColor 属性重置为其默认值。Resets the BackColor property to its default value.

ResetBindings()

使绑定到 BindingSource 的控件重新读取列表中的所有项,并刷新这些项的显示值。Causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.

(继承自 Control)
ResetCursor()

Cursor 属性重置为其默认值。Resets the Cursor property to its default value.

(继承自 Control)
ResetFont()

Font 属性重置为其默认值。Resets the Font property to its default value.

(继承自 Control)
ResetForeColor()

ForeColor 属性重置为其默认值。Resets the ForeColor property to its default value.

ResetGridLineColor()

GridLineColor 属性重置为其默认值。Resets the GridLineColor property to its default value.

ResetHeaderBackColor()

HeaderBackColor 属性重置为其默认值。Resets the HeaderBackColor property to its default value.

ResetHeaderFont()

HeaderFont 属性重置为其默认值。Resets the HeaderFont property to its default value.

ResetHeaderForeColor()

HeaderForeColor 属性重置为其默认值。Resets the HeaderForeColor property to its default value.

ResetImeMode()

ImeMode 属性重置为其默认值。Resets the ImeMode property to its default value.

(继承自 Control)
ResetLinkColor()

LinkColor 属性重置为其默认值。Resets the LinkColor property to its default value.

ResetLinkHoverColor()

LinkHoverColor 属性重置为其默认值。Resets the LinkHoverColor property to its default value.

ResetMouseEventArgs()

重置控件以处理 MouseLeave 事件。Resets the control to handle the MouseLeave event.

(继承自 Control)
ResetRightToLeft()

RightToLeft 属性重置为其默认值。Resets the RightToLeft property to its default value.

(继承自 Control)
ResetSelection()

取消选定的所有行的选择。Turns off selection for all rows that are selected.

ResetSelectionBackColor()

SelectionBackColor 属性重置为其默认值。Resets the SelectionBackColor property to its default value.

ResetSelectionForeColor()

SelectionForeColor 属性重置为其默认值。Resets the SelectionForeColor property to its default value.

ResetText()

Text 属性重置为其默认值 (Empty)。Resets the Text property to its default value (Empty).

(继承自 Control)
ResumeLayout()

恢复正常的布局逻辑。Resumes usual layout logic.

(继承自 Control)
ResumeLayout(Boolean)

恢复正常的布局逻辑,可以选择强制对挂起的布局请求立即进行布局。Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests.

(继承自 Control)
RtlTranslateAlignment(ContentAlignment)

将指定的 ContentAlignment 转换为相应的 ContentAlignment 以支持从右向左的文本。Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.

(继承自 Control)
RtlTranslateAlignment(HorizontalAlignment)

将指定的 HorizontalAlignment 转换为相应的 HorizontalAlignment 以支持从右向左的文本。Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.

(继承自 Control)
RtlTranslateAlignment(LeftRightAlignment)

将指定的 LeftRightAlignment 转换为相应的 LeftRightAlignment 以支持从右向左的文本。Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.

(继承自 Control)
RtlTranslateContent(ContentAlignment)

将指定的 ContentAlignment 转换为相应的 ContentAlignment 以支持从右向左的文本。Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.

(继承自 Control)
RtlTranslateHorizontal(HorizontalAlignment)

将指定的 HorizontalAlignment 转换为相应的 HorizontalAlignment 以支持从右向左的文本。Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.

(继承自 Control)
RtlTranslateLeftRight(LeftRightAlignment)

将指定的 LeftRightAlignment 转换为相应的 LeftRightAlignment 以支持从右向左的文本。Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.

(继承自 Control)
Scale(Single)

缩放控件和任何子控件。Scales the control and any child controls.

(继承自 Control)
Scale(Single, Single)

缩放整个控件和任何子控件。Scales the entire control and any child controls.

(继承自 Control)
Scale(SizeF)

按指定的比例因子缩放控件和所有子控件。Scales the control and all child controls by the specified scaling factor.

(继承自 Control)
ScaleBitmapLogicalToDevice(Bitmap)

发生 DPI 更改时,可以将逻辑位图值缩放到其等效设备单元值。Scales a logical bitmap value to it's equivalent device unit value when a DPI change occurs.

(继承自 Control)
ScaleControl(SizeF, BoundsSpecified)

缩放控件的位置、大小、空白和边距。Scales a control's location, size, padding and margin.

(继承自 Control)
ScaleCore(Single, Single)

此方法与此类无关。This method is not relevant for this class.

(继承自 Control)
Select()

激活控件。Activates the control.

(继承自 Control)
Select(Boolean, Boolean)

激活子控件。Activates a child control. 还可以指定从中选择控件的 Tab 键顺序的方向。Optionally specifies the direction in the tab order to select the control from.

(继承自 Control)
Select(Int32)

选择指定行。Selects a specified row.

SelectNextControl(Control, Boolean, Boolean, Boolean, Boolean)

激活下一个控件。Activates the next control.

(继承自 Control)
SendToBack()

将控件发送到 Z 顺序的后面。Sends the control to the back of the z-order.

(继承自 Control)
SetAutoSizeMode(AutoSizeMode)

设置一个值,该值指示当启用控件的 AutoSize 属性时控件的行为方式。Sets a value indicating how a control will behave when its AutoSize property is enabled.

(继承自 Control)
SetBounds(Int32, Int32, Int32, Int32)

将控件的边界设置为指定位置和大小。Sets the bounds of the control to the specified location and size.

(继承自 Control)
SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

将控件的指定边界设置为指定位置和大小。Sets the specified bounds of the control to the specified location and size.

(继承自 Control)
SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)

执行设置该控件的指定边界的工作。Performs the work of setting the specified bounds of this control.

(继承自 Control)
SetClientSizeCore(Int32, Int32)

设置控件的工作区的大小。Sets the size of the client area of the control.

(继承自 Control)
SetDataBinding(Object, String)

在运行时设置 DataSourceDataMember 属性。Sets the DataSource and DataMember properties at run time.

SetStyle(ControlStyles, Boolean)

将指定的 ControlStyles 标志设置为 truefalseSets a specified ControlStyles flag to either true or false.

(继承自 Control)
SetTopLevel(Boolean)

将控件设置为顶级控件。Sets the control as the top-level control.

(继承自 Control)
SetVisibleCore(Boolean)

将控件设置为指定的可见状态。Sets the control to the specified visible state.

(继承自 Control)
ShouldSerializeAlternatingBackColor()

指示是否应使 AlternatingBackColor 属性持久化。Indicates whether the AlternatingBackColor property should be persisted.

ShouldSerializeBackgroundColor()

指示是否应使 BackgroundColor 属性持久化。Indicates whether the BackgroundColor property should be persisted.

ShouldSerializeCaptionBackColor()

获取一个值,该值指示是否应保持 CaptionBackColor 属性不变。Gets a value indicating whether the CaptionBackColor property should be persisted.

ShouldSerializeCaptionForeColor()

获取一个值,该值指示是否应保持 CaptionForeColor 属性不变。Gets a value indicating whether the CaptionForeColor property should be persisted.

ShouldSerializeGridLineColor()

指示是否应使 GridLineColor 属性持久化。Indicates whether the GridLineColor property should be persisted.

ShouldSerializeHeaderBackColor()

指示是否应使 HeaderBackColor 属性持久化。Indicates whether the HeaderBackColor property should be persisted.

ShouldSerializeHeaderFont()

指示是否应使 HeaderFont 属性持久化。Indicates whether the HeaderFont property should be persisted.

ShouldSerializeHeaderForeColor()

指示是否应使 HeaderForeColor 属性持久化。Indicates whether the HeaderForeColor property should be persisted.

ShouldSerializeLinkHoverColor()

指示是否应使 LinkHoverColor 属性持久化。Indicates whether the LinkHoverColor property should be persisted.

ShouldSerializeParentRowsBackColor()

指示是否应使 ParentRowsBackColor 属性持久化。Indicates whether the ParentRowsBackColor property should be persisted.

ShouldSerializeParentRowsForeColor()

指示是否应使 ParentRowsForeColor 属性持久化。Indicates whether the ParentRowsForeColor property should be persisted.

ShouldSerializePreferredRowHeight()

指示是否应使 PreferredRowHeight 属性持久化。Indicates whether the PreferredRowHeight property should be persisted.

ShouldSerializeSelectionBackColor()

指示是否应使 SelectionBackColor 属性持久化。Indicates whether the SelectionBackColor property should be persisted.

ShouldSerializeSelectionForeColor()

指示是否应使 SelectionForeColor 属性持久化。Indicates whether the SelectionForeColor property should be persisted.

Show()

向用户显示控件。Displays the control to the user.

(继承自 Control)
SizeFromClientSize(Size)

确定整个控件(从控件工作区的高度和宽度起计算)的大小。Determines the size of the entire control from the height and width of its client area.

(继承自 Control)
SubObjectsSiteChange(Boolean)

从与 DataGridTableStyle 关联的容器中添加或移除 DataGrid 对象。Adds or removes the DataGridTableStyle objects from the container that is associated with the DataGrid.

SuspendLayout()

临时挂起控件的布局逻辑。Temporarily suspends the layout logic for the control.

(继承自 Control)
ToString()

返回包含 Component 的名称的 String(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

(继承自 Component)
UnSelect(Int32)

取消指定行的选定。Unselects a specified row.

Update()

使控件重绘其工作区内的无效区域。Causes the control to redraw the invalidated regions within its client area.

(继承自 Control)
UpdateBounds()

用当前大小和位置更新控件的边界。Updates the bounds of the control with the current size and location.

(继承自 Control)
UpdateBounds(Int32, Int32, Int32, Int32)

用指定大小和位置更新控件的边界。Updates the bounds of the control with the specified size and location.

(继承自 Control)
UpdateBounds(Int32, Int32, Int32, Int32, Int32, Int32)

用指定大小、位置和工作区的大小更新控件的边界。Updates the bounds of the control with the specified size, location, and client size.

(继承自 Control)
UpdateStyles()

强制将分配的样式重新应用到控件。Forces the assigned styles to be reapplied to the control.

(继承自 Control)
UpdateZOrder()

按控件的父级的 Z 顺序更新控件。Updates the control in its parent's z-order.

(继承自 Control)
WndProc(Message)

处理 Windows 消息。Processes Windows messages.

(继承自 Control)

事件

AllowNavigationChanged

AllowNavigation 属性更改后发生。Occurs when the AllowNavigation property has changed.

AutoSizeChanged

此事件与此类无关。This event is not relevant for this class.

(继承自 Control)
BackButtonClick

在单击子表上的 Back 按钮时发生。Occurs when the Back button on a child table is clicked.

BackColorChanged

BackColor 属性的值更改时发生。Occurs when the value of the BackColor property changes.

(继承自 Control)
BackgroundColorChanged

BackgroundColor 更改后发生。Occurs when the BackgroundColor has changed.

BackgroundImageChanged

BackgroundImage 属性的值更改时发生。Occurs when the value of the BackgroundImage property changes.

BackgroundImageLayoutChanged

BackgroundImageLayout 属性的值更改时发生。Occurs when the value of the BackgroundImageLayout property changes.

BindingContextChanged

BindingContext 属性的值更改时发生。Occurs when the value of the BindingContext property changes.

(继承自 Control)
BorderStyleChanged

BorderStyle 更改后发生。Occurs when the BorderStyle has changed.

CaptionVisibleChanged

CaptionVisible 属性更改后发生。Occurs when the CaptionVisible property has changed.

CausesValidationChanged

CausesValidation 属性的值更改时发生。Occurs when the value of the CausesValidation property changes.

(继承自 Control)
ChangeUICues

焦点或键盘用户界面 (UI) 提示更改时发生。Occurs when the focus or keyboard user interface (UI) cues change.

(继承自 Control)
Click

在单击控件时发生。Occurs when the control is clicked.

(继承自 Control)
ClientSizeChanged

ClientSize 属性的值更改时发生。Occurs when the value of the ClientSize property changes.

(继承自 Control)
ContextMenuChanged

ContextMenu 属性的值更改时发生。Occurs when the value of the ContextMenu property changes.

(继承自 Control)
ContextMenuStripChanged

ContextMenuStrip 属性的值更改时发生。Occurs when the value of the ContextMenuStrip property changes.

(继承自 Control)
ControlAdded

在将新控件添加到 Control.ControlCollection 时发生。Occurs when a new control is added to the Control.ControlCollection.

(继承自 Control)
ControlRemoved

在从 Control.ControlCollection 移除控件时发生。Occurs when a control is removed from the Control.ControlCollection.

(继承自 Control)
CurrentCellChanged

CurrentCell 属性更改后发生。Occurs when the CurrentCell property has changed.

CursorChanged

Cursor 属性的值更改时发生。Occurs when the value of the Cursor property changes.

DataSourceChanged

DataSource 属性值更改后发生。Occurs when the DataSource property value has changed.

Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(继承自 Component)
DockChanged

Dock 属性的值更改时发生。Occurs when the value of the Dock property changes.

(继承自 Control)
DoubleClick

在双击控件时发生。Occurs when the control is double-clicked.

(继承自 Control)
DpiChangedAfterParent

当父控件或窗体的 DPI 更改后,以编程方式更改控件的 DPI 设置时发生。Occurs when the DPI setting for a control is changed programmatically after the DPI of its parent control or form has changed.

(继承自 Control)
DpiChangedBeforeParent

父控件或窗体的 DPI 更改事件发生前,以编程方式更改控件的 DPI 设置时发生。Occurs when the DPI setting for a control is changed programmatically before a DPI change event for its parent control or form has occurred.

(继承自 Control)
DragDrop

拖放操作完成时发生。Occurs when a drag-and-drop operation is completed.

(继承自 Control)
DragEnter

在将对象拖入控件的边界时发生。Occurs when an object is dragged into the control's bounds.

(继承自 Control)
DragLeave

将对象拖出控件的边界时发生。Occurs when an object is dragged out of the control's bounds.

(继承自 Control)
DragOver

在将对象拖到控件的边界上发生。Occurs when an object is dragged over the control's bounds.

(继承自 Control)
EnabledChanged

Enabled 属性值更改后发生。Occurs when the Enabled property value has changed.

(继承自 Control)
Enter

进入控件时发生。Occurs when the control is entered.

(继承自 Control)
FlatModeChanged

FlatMode 更改后发生。Occurs when the FlatMode has changed.

FontChanged

Font 属性值更改时发生。Occurs when the Font property value changes.

(继承自 Control)
ForeColorChanged

ForeColor 属性值更改时发生。Occurs when the ForeColor property value changes.

(继承自 Control)
GiveFeedback

在执行拖动操作期间发生。Occurs during a drag operation.

(继承自 Control)
GotFocus

在控件接收焦点时发生。Occurs when the control receives focus.

(继承自 Control)
HandleCreated

在为控件创建句柄时发生。Occurs when a handle is created for the control.

(继承自 Control)
HandleDestroyed

在控件的句柄处于销毁过程中时发生。Occurs when the control's handle is in the process of being destroyed.

(继承自 Control)
HelpRequested

用户请求控件帮助时发生。Occurs when the user requests help for a control.

(继承自 Control)
ImeModeChanged

ImeMode 属性更改后发生。Occurs when the ImeMode property has changed.

(继承自 Control)
Invalidated

控件的显示要求重新绘制时发生。Occurs when a control's display requires redrawing.

(继承自 Control)
KeyDown

在控件有焦点的情况下按下键时发生。Occurs when a key is pressed while the control has focus.

(继承自 Control)
KeyPress

在控件有焦点的情况下Occurs when a character. 字符、空格或退格键时发生。space or backspace key is pressed while the control has focus.

(继承自 Control)
KeyUp

在控件有焦点的情况下释放键时发生。Occurs when a key is released while the control has focus.

(继承自 Control)
Layout

在控件应重新定位其子控件时发生。Occurs when a control should reposition its child controls.

(继承自 Control)
Leave

在输入焦点离开控件时发生。Occurs when the input focus leaves the control.

(继承自 Control)
LocationChanged

Location 属性值更改后发生。Occurs when the Location property value has changed.

(继承自 Control)
LostFocus

在控件失去焦点时发生。Occurs when the control loses focus.

(继承自 Control)
MarginChanged

在控件边距更改时发生。Occurs when the control's margin changes.

(继承自 Control)
MouseCaptureChanged

当控件失去鼠标捕获时发生。Occurs when the control loses mouse capture.

(继承自 Control)
MouseClick

用鼠标单击控件时发生。Occurs when the control is clicked by the mouse.

(继承自 Control)
MouseDoubleClick

用鼠标双击控件时发生。Occurs when the control is double clicked by the mouse.

(继承自 Control)
MouseDown

当鼠标指针位于控件上并按下鼠标键时发生。Occurs when the mouse pointer is over the control and a mouse button is pressed.

(继承自 Control)
MouseEnter

在鼠标指针进入控件时发生。Occurs when the mouse pointer enters the control.

(继承自 Control)
MouseHover

在鼠标指针停放在控件上时发生。Occurs when the mouse pointer rests on the control.

(继承自 Control)
MouseLeave

在鼠标指针离开控件时发生。Occurs when the mouse pointer leaves the control.

(继承自 Control)
MouseMove

在鼠标指针移到控件上时发生。Occurs when the mouse pointer is moved over the control.

(继承自 Control)
MouseUp

在鼠标指针在控件上并释放鼠标键时发生。Occurs when the mouse pointer is over the control and a mouse button is released.

(继承自 Control)
MouseWheel

在控件有焦点且鼠标轮移动时发生。Occurs when the mouse wheel moves while the control has focus.

(继承自 Control)
Move

在移动控件时发生。Occurs when the control is moved.

(继承自 Control)
Navigate

在用户浏览到新表时发生。Occurs when the user navigates to a new table.

PaddingChanged

在控件空白区更改时发生。Occurs when the control's padding changes.

(继承自 Control)
Paint

在重绘控件时发生。Occurs when the control is redrawn.

(继承自 Control)
ParentChanged

Parent 属性值更改时发生。Occurs when the Parent property value changes.

(继承自 Control)
ParentRowsLabelStyleChanged

在更改父行的标签样式时发生。Occurs when the label style of the parent row is changed.

ParentRowsVisibleChanged

ParentRowsVisible 属性值更改时发生。Occurs when the ParentRowsVisible property value changes.

PreviewKeyDown

在焦点位于此控件上的情况下,当有按键动作时发生(在 KeyDown 事件之前发生)。Occurs before the KeyDown event when a key is pressed while focus is on this control.

(继承自 Control)
QueryAccessibilityHelp

AccessibleObject 为辅助功能应用程序提供帮助时发生。Occurs when AccessibleObject is providing help to accessibility applications.

(继承自 Control)
QueryContinueDrag

在拖放操作期间发生,并且允许拖动源确定是否应取消拖放操作。Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled.

(继承自 Control)
ReadOnlyChanged

ReadOnly 属性值更改时发生。Occurs when the ReadOnly property value changes.

RegionChanged

Region 属性的值更改时发生。Occurs when the value of the Region property changes.

(继承自 Control)
Resize

在调整控件大小时发生。Occurs when the control is resized.

(继承自 Control)
RightToLeftChanged

RightToLeft 属性值更改时发生。Occurs when the RightToLeft property value changes.

(继承自 Control)
RowHeaderClick

单击行标题时发生。Occurs when a row header is clicked.

Scroll

在用户滚动 DataGrid 控件时发生。Occurs when the user scrolls the DataGrid control.

ShowParentDetailsButtonClick

在单击 ShowParentDetails 按钮时发生。Occurs when the ShowParentDetails button is clicked.

SizeChanged

Size 属性值更改时发生。Occurs when the Size property value changes.

(继承自 Control)
StyleChanged

在控件样式更改时发生。Occurs when the control style changes.

(继承自 Control)
SystemColorsChanged

系统颜色更改时发生。Occurs when the system colors change.

(继承自 Control)
TabIndexChanged

TabIndex 属性值更改时发生。Occurs when the TabIndex property value changes.

(继承自 Control)
TabStopChanged

TabStop 属性值更改时发生。Occurs when the TabStop property value changes.

(继承自 Control)
TextChanged

Text 属性的值更改时发生。Occurs when the value of the Text property changes.

Validated

在控件完成验证时发生。Occurs when the control is finished validating.

(继承自 Control)
Validating

在控件验证时发生。Occurs when the control is validating.

(继承自 Control)
VisibleChanged

Visible 属性值更改时发生。Occurs when the Visible property value changes.

(继承自 Control)

显式界面实现

IDropTarget.OnDragDrop(DragEventArgs)

引发 DragDrop 事件。Raises the DragDrop event.

(继承自 Control)
IDropTarget.OnDragEnter(DragEventArgs)

引发 DragEnter 事件。Raises the DragEnter event.

(继承自 Control)
IDropTarget.OnDragLeave(EventArgs)

引发 DragLeave 事件。Raises the DragLeave event.

(继承自 Control)
IDropTarget.OnDragOver(DragEventArgs)

引发 DragOver 事件。Raises the DragOver event.

(继承自 Control)

适用于

另请参阅