通过


DataGrid 类

定义

注意

DataGrid is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use DataGridView instead.

在可滚动网格中显示 ADO.NET 数据。

此类在 .NET Core 3.1 及更高版本中不可用。 请改用DataGridView控件,替换并扩展DataGrid控件。

public ref class DataGrid : System::Windows::Forms::Control, System::ComponentModel::ISupportInitialize, System::Windows::Forms::IDataGridEditingService
public class DataGrid : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize, System.Windows.Forms.IDataGridEditingService
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class DataGrid : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize, System.Windows.Forms.IDataGridEditingService
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public class DataGrid : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize, System.Windows.Forms.IDataGridEditingService
type DataGrid = class
    inherit Control
    interface ISupportInitialize
    interface IDataGridEditingService
[<System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type DataGrid = class
    inherit Control
    interface ISupportInitialize
    interface IDataGridEditingService
[<System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type DataGrid = class
    inherit Control
    interface ISupportInitialize
    interface IDataGridEditingService
Public Class DataGrid
Inherits Control
Implements IDataGridEditingService, ISupportInitialize
继承
属性
实现

示例

下面的代码示例创建一个 Windows 窗体,一个包含两DataTableDataSet对象,一个关联这两个DataRelation表。 若要显示数据,System.Windows.Forms.DataGrid控件随后通过该方法绑定到DataSetSetDataBinding该控件。 窗体上的按钮通过创建两个DataGridTableStyle对象并将每个对象设置为MappingNameTableName其中一个DataTable对象来更改网格的外观。 该示例还包含事件中的 MouseUp 代码,该代码使用 HitTest 该方法打印已单击的网格的列、行和部分。

#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

注解

此类在 .NET Core 3.1 及更高版本中不可用。 请改用控件 DataGridView

显示 System.Windows.Forms.DataGrid 类似网页链接的子表链接。 可以单击指向子表的链接。 显示子表时,标题中会显示一个后退按钮,可以单击该按钮以导航回父表。 父行中的数据显示在标题下方和列标题上方。 可以通过单击后退按钮右侧的按钮来隐藏父行信息。

若要在System.Windows.Forms.DataGrid运行时显示表,请使用SetDataBinding该方法将和DataMember属性设置为DataSource有效的数据源。 以下数据源有效:

有关类的详细信息 DataSet ,请参阅 DataSets、DataTables 和 DataViews

可以创建一个网格,使用户能够编辑数据,但阻止他们添加新行,方法是使用DataView数据源并将属性false设置为 AllowNew

数据源由 BindingManagerBase 对象进一步管理。 对于数据源中的每个表,可以从窗体的BindingContext表返回一个 BindingManagerBase 。 例如,可以通过返回关联的 BindingManagerBase 对象的属性来确定数据源包含的 Count 行数。

若要验证数据,请使用表示数据及其事件的基础对象。 例如,如果数据来自某个 DataTableDataSet,请使用 ColumnChangingRowChanging 事件。

注释

由于可以自定义列数(通过添加或删除成员GridColumnStylesCollection),行可以按列进行排序,RowNumberColumnNumber因此无法保证属性值与列DataTable的对应DataRowDataColumn索引。 因此,应避免在事件中使用 Validating 这些属性来验证数据。

若要确定选择哪个单元格,请使用 CurrentCell 该属性。 使用 Item[] 属性更改任何单元格的值,该属性可以获取单元格的行索引和列索引或单个 DataGridCell单元格。 CurrentCellChanged监视事件,以检测用户何时选择另一个单元格。

若要确定用户单击的控件的哪个部分,请使用 HitTest 事件 MouseDown 中的方法。 该方法 HitTest 返回一个 DataGrid.HitTestInfo 对象,该对象包含单击区域的行和列。

若要在运行时管理控件的外观,可用于设置颜色和题注属性的多个属性,包括 CaptionForeColorCaptionBackColorCaptionFont等。

可以通过创建 DataGridTableStyle 对象并将其添加到 GridTableStylesCollection通过 TableStyles 属性访问的对象来进一步修改显示的网格(或网格)的外观。 例如,如果DataSource设置为包含三个对象,则可以向集合中添加三DataTableDataGridTableStyleDataSet对象,每个表各有一个对象。 若要将每个DataGridTableStyle对象与一个DataTable对象同步,请将DataGridTableStyleMappingName该对象的集合设置为 TableNameDataTable 有关绑定到对象数组的详细信息,请参阅该 DataGridTableStyle.MappingName 属性。

若要创建自定义表视图,请创建某个或类的DataGridTextBoxColumn实例,并将对象添加到GridTableStylesCollection通过属性访问的对象TableStylesDataGridBoolColumn 这两个类都继承自 DataGridColumnStyle. 对于每个列样式,请将 MappingName 要显示在网格中的列的列设置为 ColumnName 。 若要隐藏列,请将其 MappingName 设置为非有效 ColumnName列。

若要设置列文本的格式,请将FormatDataGridTextBoxColumn格式设置类型和自定义日期和时间格式字符串中找到的值之一的属性。

若要绑定到 DataGrid 强类型对象数组,对象类型必须包含公共属性。 若要创建 DataGridTableStyle 显示数组的属性,请将 DataGridTableStyle.MappingName 属性设置为 typename[]typename 对象类型的名称替换的位置。 另请注意,该 MappingName 属性区分大小写;类型名称必须完全匹配。 有关示例, MappingName 请参阅该属性。

还可以绑定到 DataGrid . ArrayList. 其特征 ArrayList 是它可以包含多个类型的对象,但 DataGrid 当列表中的所有项都与第一项具有相同的类型时,它只能绑定到此类列表。 这意味着所有对象必须具有相同的类型,或者它们必须继承自与列表中的第一项相同的类。 例如,如果列表中的第一项为 a Control,则第二项可以是一个 TextBox (继承自 Control)。 另一方面,如果第一项是一个,第二个 TextBox对象不能是一个 Control。 此外,绑定 ArrayList 项时必须包含项。 空 ArrayList 将导致空网格。 此外,这些 ArrayList 对象必须包含公共属性。 绑定到 an ArrayList时,将MappingNameDataGridTableStyle“ArrayList”(类型名称)设置为“ArrayList”。

对于每个 DataGridTableStyle属性,可以设置替代控件设置 System.Windows.Forms.DataGrid 的颜色和标题属性。 但是,如果未设置这些属性,则默认使用控件的设置。 属性可以重写 DataGridTableStyle 以下属性:

若要自定义各个列的外观,请将对象添加到DataGridColumnStyleGridColumnStylesCollection通过GridColumnStyles每个DataGridTableStyle列的属性访问的对象。 若要将每个DataGridColumnStyle项与其中DataTable一个DataColumn同步,请MappingNameColumnName设置为 aDataColumn。 构造时 DataGridColumnStyle,还可以设置一个格式字符串,指定列如何显示数据。 例如,可以指定列使用短日期格式显示表中所包含的日期。

注意

始终创建 DataGridColumnStyle 对象并将其添加到 GridColumnStylesCollection 将对象添加到 DataGridTableStyle 之前 GridTableStylesCollection。 向集合中添加具有有效MappingName值的空DataGridTableStyle时,DataGridColumnStyle会自动为你生成对象。 因此,如果尝试将具有重复值的新对象添加到 <a0/> 中,将引发异常。

注释

控件 DataGridView 将替换并添加控件的功能 DataGrid ;但是,如果选择,则 DataGrid 保留控件以实现向后兼容性和将来使用。 有关详细信息,请参阅 Windows 窗体 DataGridView 和 DataGrid 控件之间的差异

构造函数

名称 说明
DataGrid()
已过时.

初始化 DataGrid 类的新实例。

属性

名称 说明
AccessibilityObject
已过时.

AccessibleObject获取分配给控件的控件。

(继承自 Control)
AccessibleDefaultActionDescription
已过时.

获取或设置控件的默认操作说明,以供辅助功能客户端应用程序使用。

(继承自 Control)
AccessibleDescription
已过时.

获取或设置辅助功能客户端应用程序使用的控件的说明。

(继承自 Control)
AccessibleName
已过时.

获取或设置辅助功能客户端应用程序使用的控件的名称。

(继承自 Control)
AccessibleRole
已过时.

获取或设置控件的可访问角色。

(继承自 Control)
AllowDrop
已过时.

获取或设置一个值,该值指示控件是否可以接受用户拖动到其中的数据。

(继承自 Control)
AllowNavigation
已过时.

获取或设置一个值,该值指示是否允许导航。

AllowSorting
已过时.

获取或设置一个值,该值指示是否可以通过单击列标题来采用网格。

AlternatingBackColor
已过时.

获取或设置网格的奇数行的背景色。

Anchor
已过时.

获取或设置控件绑定到的容器的边缘,并确定控件的父级如何调整其大小。

(继承自 Control)
AutoScrollOffset
已过时.

获取或设置此控件滚动到的位置 ScrollControlIntoView(Control)

(继承自 Control)
AutoSize
已过时.

此属性与此类无关。

(继承自 Control)
BackColor
已过时.

获取或设置网格的偶数行的背景色。

BackColor
已过时.

获取或设置控件的背景色。

(继承自 Control)
BackgroundColor
已过时.

获取或设置网格的非行区域的颜色。

BackgroundImage
已过时.

此成员对此控件没有意义。

BackgroundImageLayout
已过时.

此成员对此控件没有意义。

BindingContext
已过时.

获取或设置 BindingContext 控件。

(继承自 Control)
BorderStyle
已过时.

获取或设置网格的边框样式。

Bottom
已过时.

获取控件的下边缘与其容器工作区的上边缘之间的距离(以像素为单位)。

(继承自 Control)
Bounds
已过时.

获取或设置控件的大小和位置,包括其相对于父控件的非client 元素(以像素为单位)。

(继承自 Control)
CanEnableIme
已过时.

获取一个值,该值指示属性是否可以 ImeMode 设置为活动值,以启用 IME 支持。

(继承自 Control)
CanFocus
已过时.

获取一个值,该值指示控件是否可以接收焦点。

(继承自 Control)
CanRaiseEvents
已过时.

确定是否可以在控件上引发事件。

(继承自 Control)
CanSelect
已过时.

获取一个值,该值指示是否可以选择控件。

(继承自 Control)
CaptionBackColor
已过时.

获取或设置标题区域的背景色。

CaptionFont
已过时.

获取或设置网格标题的字体。

CaptionForeColor
已过时.

获取或设置标题区域的前景色。

CaptionText
已过时.

获取或设置网格窗口标题的文本。

CaptionVisible
已过时.

获取或设置一个值,该值指示网格的标题是否可见。

Capture
已过时.

获取或设置一个值,该值指示控件是否已捕获鼠标。

(继承自 Control)
CausesValidation
已过时.

获取或设置一个值,该值指示控件是否导致验证在收到焦点时需要验证的任何控件上执行。

(继承自 Control)
ClientRectangle
已过时.

获取表示控件工作区的矩形。

(继承自 Control)
ClientSize
已过时.

获取或设置控件工作区的高度和宽度。

(继承自 Control)
ColumnHeadersVisible
已过时.

获取或设置一个值,该值指示表的列标题是否可见。

CompanyName
已过时.

获取包含控件的应用程序的公司或创建者的名称。

(继承自 Control)
Container
已过时.

IContainer获取包含 .Component

(继承自 Component)
ContainsFocus
已过时.

获取一个值,该值指示控件或其子控件之一当前是否具有输入焦点。

(继承自 Control)
ContextMenu
已过时.

获取或设置与控件关联的快捷菜单。

(继承自 Control)
ContextMenuStrip
已过时.

获取或设置 ContextMenuStrip 与此控件关联的值。

(继承自 Control)
Controls
已过时.

获取控件中包含的控件的集合。

(继承自 Control)
Created
已过时.

获取一个值,该值指示是否已创建控件。

(继承自 Control)
CreateParams
已过时.

获取创建控件句柄时所需的创建参数。

(继承自 Control)
CurrentCell
已过时.

获取或设置具有焦点的单元格。 在设计时不可用。

CurrentRowIndex
已过时.

获取或设置当前具有焦点的行的索引。

Cursor
已过时.

此成员对此控件没有意义。

DataBindings
已过时.

获取控件的数据绑定。

(继承自 Control)
DataContext
已过时.

获取或设置用于数据绑定的数据上下文。 这是一个环境属性。

(继承自 Control)
DataMember
已过时.

获取或设置控件显示DataSourceDataGrid网格的特定列表。

DataSource
已过时.

获取或设置网格显示其数据的数据源。

DefaultCursor
已过时.

获取或设置控件的默认游标。

(继承自 Control)
DefaultImeMode
已过时.

获取控件支持的默认输入法编辑器 (IME) 模式。

(继承自 Control)
DefaultMargin
已过时.

获取默认情况下在控件之间指定的空间(以像素为单位)。

(继承自 Control)
DefaultMaximumSize
已过时.

获取指定为控件的默认最大大小的长度和高度(以像素为单位)。

(继承自 Control)
DefaultMinimumSize
已过时.

获取指定为控件的默认最小大小的长度和高度(以像素为单位)。

(继承自 Control)
DefaultPadding
已过时.

获取控件内容的默认内部间距(以像素为单位)。

(继承自 Control)
DefaultSize
已过时.

获取控件的默认大小。

DefaultSize
已过时.

获取控件的默认大小。

(继承自 Control)
DesignMode
已过时.

获取一个值,该值指示当前是否 Component 处于设计模式。

(继承自 Component)
DeviceDpi
已过时.

获取当前显示控件的显示设备的 DPI 值。

(继承自 Control)
DisplayRectangle
已过时.

获取表示控件的显示区域的矩形。

(继承自 Control)
Disposing
已过时.

获取一个值,该值指示基 Control 类是否正在处理。

(继承自 Control)
Dock
已过时.

获取或设置哪些控件边框停靠到其父控件,并确定控件如何调整其父级的大小。

(继承自 Control)
DoubleBuffered
已过时.

获取或设置一个值,该值指示此控件是否应使用辅助缓冲区重新绘制其表面以减少或防止闪烁。

(继承自 Control)
Enabled
已过时.

获取或设置一个值,该值指示控件是否可以响应用户交互。

(继承自 Control)
Events
已过时.

获取附加到此 Component对象的事件处理程序的列表。

(继承自 Component)
FirstVisibleColumn
已过时.

获取网格中第一个可见列的索引。

FlatMode
已过时.

获取或设置一个值,该值指示网格是否以平面模式显示。

Focused
已过时.

获取一个值,该值指示控件是否具有输入焦点。

(继承自 Control)
Font
已过时.

获取或设置控件显示的文本的字体。

(继承自 Control)
FontHeight
已过时.

获取或设置控件字体的高度。

(继承自 Control)
ForeColor
已过时.

获取或设置控件的前景色(通常是文本的颜色) 属性 DataGrid

ForeColor
已过时.

获取或设置控件的前景色。

(继承自 Control)
GridLineColor
已过时.

获取或设置网格线的颜色。

GridLineStyle
已过时.

获取或设置网格的线条样式。

Handle
已过时.

获取控件绑定到的窗口句柄。

(继承自 Control)
HasChildren
已过时.

获取一个值,该值指示控件是否包含一个或多个子控件。

(继承自 Control)
HeaderBackColor
已过时.

获取或设置所有行标题和列标题的背景色。

HeaderFont
已过时.

获取或设置用于列标题的字体。

HeaderForeColor
已过时.

获取或设置标头的前景色。

Height
已过时.

获取或设置控件的高度。

(继承自 Control)
HorizScrollBar
已过时.

获取网格的水平滚动条。

ImeMode
已过时.

获取或设置控件的输入法编辑器 (IME) 模式。

(继承自 Control)
ImeModeBase
已过时.

获取或设置控件的 IME 模式。

(继承自 Control)
InvokeRequired
已过时.

获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用调用方法,因为调用方与创建控件的线程不同。

(继承自 Control)
IsAccessible
已过时.

获取或设置一个值,该值指示控件是否对辅助功能应用程序可见。

(继承自 Control)
IsAncestorSiteInDesignMode
已过时.

指示此控件的上级位置之一是否位于 DesignMode 中。 此属性为只读。

(继承自 Control)
IsDisposed
已过时.

获取一个值,该值指示控件是否已释放。

(继承自 Control)
IsHandleCreated
已过时.

获取一个值,该值指示控件是否具有与之关联的句柄。

(继承自 Control)
IsMirrored
已过时.

获取一个值,该值指示控件是否镜像。

(继承自 Control)
Item[DataGridCell]
已过时.

获取或设置指定 DataGridCell值。

Item[Int32, Int32]
已过时.

获取或设置指定行和列处单元格的值。

LayoutEngine
已过时.

获取控件布局引擎的缓存实例。

(继承自 Control)
Left
已过时.

获取或设置控件左边缘与其容器工作区的左边缘之间的距离(以像素为单位)。

(继承自 Control)
LinkColor
已过时.

获取或设置可以单击以导航到子表的文本的颜色。

LinkHoverColor
已过时.

此成员对此控件没有意义。

ListManager
已过时.

获取 CurrencyManagerDataGrid 控件。

Location
已过时.

获取或设置控件左上角相对于其容器左上角的坐标。

(继承自 Control)
Margin
已过时.

获取或设置控件之间的间距。

(继承自 Control)
MaximumSize
已过时.

获取或设置可指定上限 GetPreferredSize(Size) 的大小。

(继承自 Control)
MinimumSize
已过时.

获取或设置可以指定的下限 GetPreferredSize(Size) 的大小。

(继承自 Control)
Name
已过时.

获取或设置控件的名称。

(继承自 Control)
Padding
已过时.

获取或设置控件中的填充。

(继承自 Control)
Parent
已过时.

获取或设置控件的父容器。

(继承自 Control)
ParentRowsBackColor
已过时.

获取或设置父行的背景色。

ParentRowsForeColor
已过时.

获取或设置父行的前景色。

ParentRowsLabelStyle
已过时.

获取或设置父行标签的显示方式。

ParentRowsVisible
已过时.

获取或设置一个值,该值指示表的父行是否可见。

PreferredColumnWidth
已过时.

获取或设置网格列的默认宽度(以像素为单位)。

PreferredRowHeight
已过时.

获取或设置控件的首选行高度 DataGrid

PreferredSize
已过时.

获取控件可以容纳到的矩形区域的大小。

(继承自 Control)
ProductName
已过时.

获取包含控件的程序集的产品名称。

(继承自 Control)
ProductVersion
已过时.

获取包含控件的程序集的版本。

(继承自 Control)
ReadOnly
已过时.

获取或设置一个值,该值指示网格是否处于只读模式。

RecreatingHandle
已过时.

获取一个值,该值指示控件当前是否正在重新创建其句柄。

(继承自 Control)
Region
已过时.

获取或设置与控件关联的窗口区域。

(继承自 Control)
RenderRightToLeft
已过时.
已过时.

此属性现已过时。

(继承自 Control)
ResizeRedraw
已过时.

获取或设置一个值,该值指示控件在调整大小时是否重新绘制自身。

(继承自 Control)
Right
已过时.

获取控件右边缘与其容器工作区的左边缘之间的距离(以像素为单位)。

(继承自 Control)
RightToLeft
已过时.

获取或设置一个值,该值指示控件的元素是否对齐以支持使用从右到左字体的区域设置。

(继承自 Control)
RowHeadersVisible
已过时.

获取或设置一个值,该值指定行标题是否可见。

RowHeaderWidth
已过时.

获取或设置行标题的宽度。

ScaleChildren
已过时.

获取一个值,该值确定子控件的缩放。

(继承自 Control)
SelectionBackColor
已过时.

获取或设置所选行的背景色。

SelectionForeColor
已过时.

获取或设置所选行的前景色。

ShowFocusCues
已过时.

获取一个值,该值指示控件是否应显示焦点矩形。

(继承自 Control)
ShowKeyboardCues
已过时.

获取一个值,该值指示用户界面是否处于适当的状态以显示或隐藏键盘加速器。

(继承自 Control)
Site
已过时.

获取或设置控件的站点。

Site
已过时.

获取或设置控件的站点。

(继承自 Control)
Size
已过时.

获取或设置控件的高度和宽度。

(继承自 Control)
TabIndex
已过时.

获取或设置控件在其容器中的 Tab 键顺序。

(继承自 Control)
TableStyles
已过时.

获取网格的对象集合 DataGridTableStyle

TabStop
已过时.

获取或设置一个值,该值指示用户是否可以使用 TAB 键向此控件提供焦点。

(继承自 Control)
Tag
已过时.

获取或设置包含有关控件的数据的对象。

(继承自 Control)
Text
已过时.

此成员对此控件没有意义。

Top
已过时.

获取或设置控件上边缘与其容器工作区上边缘之间的距离(以像素为单位)。

(继承自 Control)
TopLevelControl
已过时.

获取其他 Windows 窗体控件未父控件的父控件。 通常,这是控件包含在的最外层 Form

(继承自 Control)
UseWaitCursor
已过时.

获取或设置一个值,该值指示是否对当前控件和所有子控件使用等待游标。

(继承自 Control)
VertScrollBar
已过时.

获取控件的垂直滚动条。

Visible
已过时.

获取或设置一个值,该值指示是否显示控件及其所有子控件。

(继承自 Control)
VisibleColumnCount
已过时.

获取可见列的数目。

VisibleRowCount
已过时.

获取可见的行数。

Width
已过时.

获取或设置控件的宽度。

(继承自 Control)
WindowTarget
已过时.

此属性与此类无关。

(继承自 Control)

方法

名称 说明
AccessibilityNotifyClients(AccessibleEvents, Int32, Int32)
已过时.

通知为指定的子控件指定的 AccessibleEvents 辅助功能客户端应用程序。

(继承自 Control)
AccessibilityNotifyClients(AccessibleEvents, Int32)
已过时.

通知为指定的子控件指定的 AccessibleEvents 辅助功能客户端应用程序。

(继承自 Control)
BeginEdit(DataGridColumnStyle, Int32)
已过时.

尝试将网格置于允许编辑的状态。

BeginInit()
已过时.

DataGrid开始初始化窗体或由另一个组件使用的初始化。 初始化在运行时发生。

BeginInvoke(Action)
已过时.

在创建控件的基础句柄的线程上异步执行指定的委托。

(继承自 Control)
BeginInvoke(Delegate, Object[])
已过时.

在创建控件的基础句柄的线程上,使用指定的参数异步执行指定的委托。

(继承自 Control)
BeginInvoke(Delegate)
已过时.

在创建控件的基础句柄的线程上异步执行指定的委托。

(继承自 Control)
BringToFront()
已过时.

将控件置于 z 顺序的前面。

(继承自 Control)
CancelEditing()
已过时.

取消当前编辑操作并回滚所有更改。

Collapse(Int32)
已过时.

折叠子关系(如果所有行存在)或指定行。

ColumnStartedEditing(Control)
已过时.

DataGrid当用户开始使用指定控件编辑列时通知控件。

ColumnStartedEditing(Rectangle)
已过时.

DataGrid当用户开始在指定位置编辑列时通知控件。

Contains(Control)
已过时.

检索一个值,该值指示指定的控件是否为控件的子级。

(继承自 Control)
CreateAccessibilityInstance()
已过时.

为此控件构造辅助功能对象的新实例。

CreateAccessibilityInstance()
已过时.

为控件创建新的辅助功能对象。

(继承自 Control)
CreateControl()
已过时.

强制创建可见控件,包括创建句柄和任何可见子控件。

(继承自 Control)
CreateControlsInstance()
已过时.

为控件创建控件集合的新实例。

(继承自 Control)
CreateGraphics()
已过时.

Graphics创建控件。

(继承自 Control)
CreateGridColumn(PropertyDescriptor, Boolean)
已过时.

使用指定的PropertyDescriptor创建 。DataGridColumnStyle

CreateGridColumn(PropertyDescriptor)
已过时.

使用指定的PropertyDescriptor值创建一个新DataGridColumnStyle项。

CreateHandle()
已过时.

为控件创建句柄。

(继承自 Control)
CreateObjRef(Type)
已过时.

创建一个对象,其中包含生成用于与远程对象通信的代理所需的所有相关信息。

(继承自 MarshalByRefObject)
DefWndProc(Message)
已过时.

将指定的消息发送到默认窗口过程。

(继承自 Control)
DestroyHandle()
已过时.

销毁与控件关联的句柄。

(继承自 Control)
Dispose()
已过时.

释放该 Component命令使用的所有资源。

(继承自 Component)
Dispose(Boolean)
已过时.

释放由 <a0/&a0> 使用的资源(内存以外的资源)。

Dispose(Boolean)
已过时.

释放由及其子控件使用 Control 的非托管资源,并选择性地释放托管资源。

(继承自 Control)
DoDragDrop(Object, DragDropEffects, Bitmap, Point, Boolean)
已过时.

开始拖动操作。

(继承自 Control)
DoDragDrop(Object, DragDropEffects)
已过时.

开始拖放操作。

(继承自 Control)
DoDragDropAsJson<T>(T, DragDropEffects, Bitmap, Point, Boolean)
已过时.

在可滚动网格中显示 ADO.NET 数据。

此类在 .NET Core 3.1 及更高版本中不可用。 请改用DataGridView控件,替换并扩展DataGrid控件。

(继承自 Control)
DoDragDropAsJson<T>(T, DragDropEffects)
已过时.

在可滚动网格中显示 ADO.NET 数据。

此类在 .NET Core 3.1 及更高版本中不可用。 请改用DataGridView控件,替换并扩展DataGrid控件。

(继承自 Control)
DrawToBitmap(Bitmap, Rectangle)
已过时.

支持呈现到指定的位图。

(继承自 Control)
EndEdit(DataGridColumnStyle, Int32, Boolean)
已过时.

请求对控件执行编辑操作的 DataGrid 结束。

EndInit()
已过时.

结束在窗体上使用或 DataGrid 由另一个组件使用的初始化。 初始化在运行时发生。

EndInvoke(IAsyncResult)
已过时.

检索传递的异步操作 IAsyncResult 的返回值。

(继承自 Control)
Equals(Object)
已过时.

确定指定的对象是否等于当前对象。

(继承自 Object)
Expand(Int32)
已过时.

显示所有行或特定行的子关系(如果有)。

FindForm()
已过时.

检索控件打开的窗体。

(继承自 Control)
Focus()
已过时.

将输入焦点设置为控件。

(继承自 Control)
GetAccessibilityObjectById(Int32)
已过时.

检索指定的 AccessibleObject

(继承自 Control)
GetAutoSizeMode()
已过时.

检索一个值,该值指示控件在启用控件 AutoSize 属性时的行为方式。

(继承自 Control)
GetCellBounds(DataGridCell)
已过时.

Rectangle获取由 DataGridCell. 指定的单元格的单元格。

GetCellBounds(Int32, Int32)
已过时.

Rectangle获取行号和列号指定的单元格。

GetChildAtPoint(Point, GetChildAtPointSkip)
已过时.

检索位于指定坐标处的子控件,指定是否忽略特定类型的子控件。

(继承自 Control)
GetChildAtPoint(Point)
已过时.

检索位于指定坐标处的子控件。

(继承自 Control)
GetContainerControl()
已过时.

返回控件的父控件链的下一个 ContainerControl

(继承自 Control)
GetCurrentCellBounds()
已过时.

获取一个 Rectangle 值,该值指定所选单元格的四个角。

GetHashCode()
已过时.

用作默认哈希函数。

(继承自 Object)
GetLifetimeService()
已过时.

检索控制此实例的生存期策略的当前生存期服务对象。

(继承自 MarshalByRefObject)
GetNextControl(Control, Boolean)
已过时.

按子控件的 Tab 键顺序检索下一个控件向前或后退。

(继承自 Control)
GetOutputTextDelimiter()
已过时.

获取在将行内容复制到剪贴板时列之间的分隔符的字符串。

GetPreferredSize(Size)
已过时.

检索可安装控件的矩形区域的大小。

(继承自 Control)
GetScaledBounds(Rectangle, SizeF, BoundsSpecified)
已过时.

检索在其中缩放控件的边界。

(继承自 Control)
GetService(Type)
已过时.

返回一个对象,该对象表示服务由 Component 或其 Container提供的服务。

(继承自 Component)
GetStyle(ControlStyles)
已过时.

检索控件的指定控件样式位的值。

(继承自 Control)
GetTopLevel()
已过时.

确定控件是否为顶级控件。

(继承自 Control)
GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
GridHScrolled(Object, ScrollEventArgs)
已过时.

侦听水平滚动条的滚动事件。

GridVScrolled(Object, ScrollEventArgs)
已过时.

侦听垂直滚动条的滚动事件。

Hide()
已过时.

隐藏用户的控件。

(继承自 Control)
HitTest(Int32, Int32)
已过时.

使用传递给方法的 x 和 y 坐标获取网格中单击点的行号和列号等信息。

HitTest(Point)
已过时.

获取有关使用特定 Point网格的单击点的行号和列号等信息。

InitializeLifetimeService()
已过时.

获取生存期服务对象来控制此实例的生存期策略。

(继承自 MarshalByRefObject)
InitLayout()
已过时.

在控件添加到另一个容器后调用。

(继承自 Control)
Invalidate()
已过时.

使控件的整个图面失效,并使控件重新绘制。

(继承自 Control)
Invalidate(Boolean)
已过时.

使控件的特定区域失效,并导致绘制消息发送到控件。 (可选)使分配给控件的子控件失效。

(继承自 Control)
Invalidate(Rectangle, Boolean)
已过时.

使控件的指定区域失效(将其添加到控件的更新区域,即将在下一次绘制操作时重新绘制的区域),并导致绘制消息发送到控件。 (可选)使分配给控件的子控件失效。

(继承自 Control)
Invalidate(Rectangle)
已过时.

使控件的指定区域失效(将其添加到控件的更新区域,即将在下一次绘制操作时重新绘制的区域),并导致绘制消息发送到控件。

(继承自 Control)
Invalidate(Region, Boolean)
已过时.

使控件的指定区域失效(将其添加到控件的更新区域,即将在下一次绘制操作时重新绘制的区域),并导致绘制消息发送到控件。 (可选)使分配给控件的子控件失效。

(继承自 Control)
Invalidate(Region)
已过时.

使控件的指定区域失效(将其添加到控件的更新区域,即将在下一次绘制操作时重新绘制的区域),并导致绘制消息发送到控件。

(继承自 Control)
Invoke(Action)
已过时.

在拥有控件的基础窗口句柄的线程上执行指定的委托。

(继承自 Control)
Invoke(Delegate, Object[])
已过时.

在拥有控件的基础窗口句柄的线程上,使用指定的参数列表执行指定的委托。

(继承自 Control)
Invoke(Delegate)
已过时.

在拥有控件的基础窗口句柄的线程上执行指定的委托。

(继承自 Control)
Invoke<T>(Func<T>)
已过时.

在拥有控件的基础窗口句柄的线程上执行指定的委托。

(继承自 Control)
InvokeAsync(Action, CancellationToken)
已过时.

在拥有控件句柄的线程上异步调用指定的同步回调。

(继承自 Control)
InvokeAsync(Func<CancellationToken,ValueTask>, CancellationToken)
已过时.

在拥有控件句柄的线程上执行指定的异步回调。

(继承自 Control)
InvokeAsync<T>(Func<CancellationToken,ValueTask<T>>, CancellationToken)
已过时.

在拥有控件句柄的线程上执行指定的异步回调。

(继承自 Control)
InvokeAsync<T>(Func<T>, CancellationToken)
已过时.

在拥有控件句柄的线程上异步调用指定的同步回调。

(继承自 Control)
InvokeGotFocus(Control, EventArgs)
已过时.

GotFocus引发指定控件的事件。

(继承自 Control)
InvokeLostFocus(Control, EventArgs)
已过时.

LostFocus引发指定控件的事件。

(继承自 Control)
InvokeOnClick(Control, EventArgs)
已过时.

Click引发指定控件的事件。

(继承自 Control)
InvokePaint(Control, PaintEventArgs)
已过时.

Paint引发指定控件的事件。

(继承自 Control)
InvokePaintBackground(Control, PaintEventArgs)
已过时.

PaintBackground引发指定控件的事件。

(继承自 Control)
IsExpanded(Int32)
已过时.

获取一个值,该值指示指定行的节点是展开还是折叠。

IsInputChar(Char)
已过时.

确定字符是否是控件识别的输入字符。

(继承自 Control)
IsInputKey(Keys)
已过时.

确定指定的键是常规输入键还是需要预处理的特殊键。

(继承自 Control)
IsSelected(Int32)
已过时.

获取一个值,该值指示是否选择了指定的行。

LogicalToDeviceUnits(Int32)
已过时.

将逻辑 DPI 值转换为其等效的 DeviceUnit DPI 值。

(继承自 Control)
LogicalToDeviceUnits(Size)
已过时.

通过缩放当前 DPI 的大小并将其舍入为最接近的整数值(宽度和高度)从逻辑单位转换为设备单位。

(继承自 Control)
MemberwiseClone()
已过时.

创建当前 Object的浅表副本。

(继承自 Object)
MemberwiseClone(Boolean)
已过时.

创建当前 MarshalByRefObject 对象的浅表副本。

(继承自 MarshalByRefObject)
NavigateBack()
已过时.

导航回到之前显示在网格中的表。

NavigateTo(Int32, String)
已过时.

导航到按行名和关系名称指定的表。

NotifyInvalidate(Rectangle)
已过时.

Invalidated使用控件的指定区域引发事件,使该事件失效。

(继承自 Control)
OnAllowNavigationChanged(EventArgs)
已过时.

引发 AllowNavigationChanged 事件。

OnAutoSizeChanged(EventArgs)
已过时.

引发 AutoSizeChanged 事件。

(继承自 Control)
OnBackButtonClicked(Object, EventArgs)
已过时.

侦听标题的后退按钮单击事件。

OnBackColorChanged(EventArgs)
已过时.

引发 BackColorChanged 事件。

OnBackColorChanged(EventArgs)
已过时.

引发 BackColorChanged 事件。

(继承自 Control)
OnBackgroundColorChanged(EventArgs)
已过时.

引发 BackgroundColorChanged 事件。

OnBackgroundImageChanged(EventArgs)
已过时.

引发 BackgroundImageChanged 事件。

(继承自 Control)
OnBackgroundImageLayoutChanged(EventArgs)
已过时.

引发 BackgroundImageLayoutChanged 事件。

(继承自 Control)
OnBindingContextChanged(EventArgs)
已过时.

引发 BindingContextChanged 事件。

OnBindingContextChanged(EventArgs)
已过时.

引发 BindingContextChanged 事件。

(继承自 Control)
OnBorderStyleChanged(EventArgs)
已过时.

引发 BorderStyleChanged 事件。

OnCaptionVisibleChanged(EventArgs)
已过时.

引发 CaptionVisibleChanged 事件。

OnCausesValidationChanged(EventArgs)
已过时.

引发 CausesValidationChanged 事件。

(继承自 Control)
OnChangeUICues(UICuesEventArgs)
已过时.

引发 ChangeUICues 事件。

(继承自 Control)
OnClick(EventArgs)
已过时.

引发 Click 事件。

(继承自 Control)
OnClientSizeChanged(EventArgs)
已过时.

引发 ClientSizeChanged 事件。

(继承自 Control)
OnContextMenuChanged(EventArgs)
已过时.

引发 ContextMenuChanged 事件。

(继承自 Control)
OnContextMenuStripChanged(EventArgs)
已过时.

引发 ContextMenuStripChanged 事件。

(继承自 Control)
OnControlAdded(ControlEventArgs)
已过时.

引发 ControlAdded 事件。

(继承自 Control)
OnControlRemoved(ControlEventArgs)
已过时.

引发 ControlRemoved 事件。

(继承自 Control)
OnCreateControl()
已过时.

CreateControl()引发方法。

(继承自 Control)
OnCurrentCellChanged(EventArgs)
已过时.

引发 CurrentCellChanged 事件。

OnCursorChanged(EventArgs)
已过时.

引发 CursorChanged 事件。

(继承自 Control)
OnDataContextChanged(EventArgs)
已过时.

在可滚动网格中显示 ADO.NET 数据。

此类在 .NET Core 3.1 及更高版本中不可用。 请改用DataGridView控件,替换并扩展DataGrid控件。

(继承自 Control)
OnDataSourceChanged(EventArgs)
已过时.

引发 DataSourceChanged 事件。

OnDockChanged(EventArgs)
已过时.

引发 DockChanged 事件。

(继承自 Control)
OnDoubleClick(EventArgs)
已过时.

引发 DoubleClick 事件。

(继承自 Control)
OnDpiChangedAfterParent(EventArgs)
已过时.

引发 DpiChangedAfterParent 事件。

(继承自 Control)
OnDpiChangedBeforeParent(EventArgs)
已过时.

引发 DpiChangedBeforeParent 事件。

(继承自 Control)
OnDragDrop(DragEventArgs)
已过时.

引发 DragDrop 事件。

(继承自 Control)
OnDragEnter(DragEventArgs)
已过时.

引发 DragEnter 事件。

(继承自 Control)
OnDragLeave(EventArgs)
已过时.

引发 DragLeave 事件。

(继承自 Control)
OnDragOver(DragEventArgs)
已过时.

引发 DragOver 事件。

(继承自 Control)
OnEnabledChanged(EventArgs)
已过时.

引发 EnabledChanged 事件。

(继承自 Control)
OnEnter(EventArgs)
已过时.

引发 Enter 事件。

OnEnter(EventArgs)
已过时.

引发 Enter 事件。

(继承自 Control)
OnFlatModeChanged(EventArgs)
已过时.

引发 FlatModeChanged 事件。

OnFontChanged(EventArgs)
已过时.

引发 FontChanged 事件。

OnFontChanged(EventArgs)
已过时.

引发 FontChanged 事件。

(继承自 Control)
OnForeColorChanged(EventArgs)
已过时.

引发 ForeColorChanged 事件。

OnForeColorChanged(EventArgs)
已过时.

引发 ForeColorChanged 事件。

(继承自 Control)
OnGiveFeedback(GiveFeedbackEventArgs)
已过时.

引发 GiveFeedback 事件。

(继承自 Control)
OnGotFocus(EventArgs)
已过时.

引发 GotFocus 事件。

(继承自 Control)
OnHandleCreated(EventArgs)
已过时.

引发 CreateHandle() 事件。

OnHandleCreated(EventArgs)
已过时.

引发 HandleCreated 事件。

(继承自 Control)
OnHandleDestroyed(EventArgs)
已过时.

引发 DestroyHandle() 事件。

OnHandleDestroyed(EventArgs)
已过时.

引发 HandleDestroyed 事件。

(继承自 Control)
OnHelpRequested(HelpEventArgs)
已过时.

引发 HelpRequested 事件。

(继承自 Control)
OnImeModeChanged(EventArgs)
已过时.

引发 ImeModeChanged 事件。

(继承自 Control)
OnInvalidated(InvalidateEventArgs)
已过时.

引发 Invalidated 事件。

(继承自 Control)
OnKeyDown(KeyEventArgs)
已过时.

引发 KeyDown 事件。

OnKeyDown(KeyEventArgs)
已过时.

引发 KeyDown 事件。

(继承自 Control)
OnKeyPress(KeyPressEventArgs)
已过时.

引发 KeyPress 事件。

OnKeyPress(KeyPressEventArgs)
已过时.

引发 KeyPress 事件。

(继承自 Control)
OnKeyUp(KeyEventArgs)
已过时.

引发 KeyUp 事件。

(继承自 Control)
OnLayout(LayoutEventArgs)
已过时.

引发重新 Layout 定位控件和更新滚动条的事件。

OnLayout(LayoutEventArgs)
已过时.

引发 Layout 事件。

(继承自 Control)
OnLeave(EventArgs)
已过时.

引发 Leave 事件。

OnLeave(EventArgs)
已过时.

引发 Leave 事件。

(继承自 Control)
OnLocationChanged(EventArgs)
已过时.

引发 LocationChanged 事件。

(继承自 Control)
OnLostFocus(EventArgs)
已过时.

引发 LostFocus 事件。

(继承自 Control)
OnMarginChanged(EventArgs)
已过时.

引发 MarginChanged 事件。

(继承自 Control)
OnMouseCaptureChanged(EventArgs)
已过时.

引发 MouseCaptureChanged 事件。

(继承自 Control)
OnMouseClick(MouseEventArgs)
已过时.

引发 MouseClick 事件。

(继承自 Control)
OnMouseDoubleClick(MouseEventArgs)
已过时.

引发 MouseDoubleClick 事件。

(继承自 Control)
OnMouseDown(MouseEventArgs)
已过时.

引发 MouseDown 事件。

OnMouseDown(MouseEventArgs)
已过时.

引发 MouseDown 事件。

(继承自 Control)
OnMouseEnter(EventArgs)
已过时.

引发 MouseEnter 事件。

(继承自 Control)
OnMouseHover(EventArgs)
已过时.

引发 MouseHover 事件。

(继承自 Control)
OnMouseLeave(EventArgs)
已过时.

MouseLeave创建事件。

OnMouseLeave(EventArgs)
已过时.

引发 MouseLeave 事件。

(继承自 Control)
OnMouseMove(MouseEventArgs)
已过时.

引发 MouseMove 事件。

OnMouseMove(MouseEventArgs)
已过时.

引发 MouseMove 事件。

(继承自 Control)
OnMouseUp(MouseEventArgs)
已过时.

引发 MouseUp 事件。

OnMouseUp(MouseEventArgs)
已过时.

引发 MouseUp 事件。

(继承自 Control)
OnMouseWheel(MouseEventArgs)
已过时.

引发 MouseWheel 事件。

OnMouseWheel(MouseEventArgs)
已过时.

引发 MouseWheel 事件。

(继承自 Control)
OnMove(EventArgs)
已过时.

引发 Move 事件。

(继承自 Control)
OnNavigate(NavigateEventArgs)
已过时.

引发 Navigate 事件。

OnNotifyMessage(Message)
已过时.

通知 Windows 消息的控制。

(继承自 Control)
OnPaddingChanged(EventArgs)
已过时.

引发 PaddingChanged 事件。

(继承自 Control)
OnPaint(PaintEventArgs)
已过时.

引发 Paint 事件。

OnPaint(PaintEventArgs)
已过时.

引发 Paint 事件。

(继承自 Control)
OnPaintBackground(PaintEventArgs)
已过时.

OnPaintBackground(PaintEventArgs)替代以防止绘制控件的背景DataGrid

OnPaintBackground(PaintEventArgs)
已过时.

绘制控件的背景。

(继承自 Control)
OnParentBackColorChanged(EventArgs)
已过时.

BackColorChanged当控件容器的属性值更改时BackColor引发事件。

(继承自 Control)
OnParentBackgroundImageChanged(EventArgs)
已过时.

BackgroundImageChanged当控件容器的属性值更改时BackgroundImage引发事件。

(继承自 Control)
OnParentBindingContextChanged(EventArgs)
已过时.

BindingContextChanged当控件容器的属性值更改时BindingContext引发事件。

(继承自 Control)
OnParentChanged(EventArgs)
已过时.

引发 ParentChanged 事件。

(继承自 Control)
OnParentCursorChanged(EventArgs)
已过时.

引发 CursorChanged 事件。

(继承自 Control)
OnParentDataContextChanged(EventArgs)
已过时.

在可滚动网格中显示 ADO.NET 数据。

此类在 .NET Core 3.1 及更高版本中不可用。 请改用DataGridView控件,替换并扩展DataGrid控件。

(继承自 Control)
OnParentEnabledChanged(EventArgs)
已过时.

EnabledChanged当控件容器的属性值更改时Enabled引发事件。

(继承自 Control)
OnParentFontChanged(EventArgs)
已过时.

FontChanged当控件容器的属性值更改时Font引发事件。

(继承自 Control)
OnParentForeColorChanged(EventArgs)
已过时.

ForeColorChanged当控件容器的属性值更改时ForeColor引发事件。

(继承自 Control)
OnParentRightToLeftChanged(EventArgs)
已过时.

RightToLeftChanged当控件容器的属性值更改时RightToLeft引发事件。

(继承自 Control)
OnParentRowsLabelStyleChanged(EventArgs)
已过时.

引发 ParentRowsLabelStyleChanged 事件。

OnParentRowsVisibleChanged(EventArgs)
已过时.

引发 ParentRowsVisibleChanged 事件。

OnParentVisibleChanged(EventArgs)
已过时.

VisibleChanged当控件容器的属性值更改时Visible引发事件。

(继承自 Control)
OnPreviewKeyDown(PreviewKeyDownEventArgs)
已过时.

引发 PreviewKeyDown 事件。

(继承自 Control)
OnPrint(PaintEventArgs)
已过时.

引发 Paint 事件。

(继承自 Control)
OnQueryContinueDrag(QueryContinueDragEventArgs)
已过时.

引发 QueryContinueDrag 事件。

(继承自 Control)
OnReadOnlyChanged(EventArgs)
已过时.

引发 ReadOnlyChanged 事件。

OnRegionChanged(EventArgs)
已过时.

引发 RegionChanged 事件。

(继承自 Control)
OnResize(EventArgs)
已过时.

引发 Resize 事件。

OnResize(EventArgs)
已过时.

引发 Resize 事件。

(继承自 Control)
OnRightToLeftChanged(EventArgs)
已过时.

引发 RightToLeftChanged 事件。

(继承自 Control)
OnRowHeaderClick(EventArgs)
已过时.

引发 RowHeaderClick 事件。

OnScroll(EventArgs)
已过时.

引发 Scroll 事件。

OnShowParentDetailsButtonClicked(Object, EventArgs)
已过时.

引发 ShowParentDetailsButtonClick 事件。

OnSizeChanged(EventArgs)
已过时.

引发 SizeChanged 事件。

(继承自 Control)
OnStyleChanged(EventArgs)
已过时.

引发 StyleChanged 事件。

(继承自 Control)
OnSystemColorsChanged(EventArgs)
已过时.

引发 SystemColorsChanged 事件。

(继承自 Control)
OnTabIndexChanged(EventArgs)
已过时.

引发 TabIndexChanged 事件。

(继承自 Control)
OnTabStopChanged(EventArgs)
已过时.

引发 TabStopChanged 事件。

(继承自 Control)
OnTextChanged(EventArgs)
已过时.

引发 TextChanged 事件。

(继承自 Control)
OnValidated(EventArgs)
已过时.

引发 Validated 事件。

(继承自 Control)
OnValidating(CancelEventArgs)
已过时.

引发 Validating 事件。

(继承自 Control)
OnVisibleChanged(EventArgs)
已过时.

引发 VisibleChanged 事件。

(继承自 Control)
PerformLayout()
已过时.

强制控件将布局逻辑应用于其所有子控件。

(继承自 Control)
PerformLayout(Control, String)
已过时.

强制控件将布局逻辑应用于其所有子控件。

(继承自 Control)
PointToClient(Point)
已过时.

将指定屏幕点的位置计算为客户端坐标。

(继承自 Control)
PointToScreen(Point)
已过时.

将指定客户端点的位置计算为屏幕坐标。

(继承自 Control)
PreProcessControlMessage(Message)
已过时.

在调度键盘或输入消息之前,预处理消息循环中的键盘或输入消息。

(继承自 Control)
PreProcessMessage(Message)
已过时.

在调度键盘或输入消息之前,预处理消息循环中的键盘或输入消息。

(继承自 Control)
ProcessCmdKey(Message, Keys)
已过时.

处理命令键。

(继承自 Control)
ProcessDialogChar(Char)
已过时.

处理对话字符。

(继承自 Control)
ProcessDialogKey(Keys)
已过时.

获取或设置一个值,该值指示是否应进一步处理键。

ProcessDialogKey(Keys)
已过时.

处理对话键。

(继承自 Control)
ProcessGridKey(KeyEventArgs)
已过时.

处理网格导航的键。

ProcessKeyEventArgs(Message)
已过时.

处理键消息并生成相应的控制事件。

(继承自 Control)
ProcessKeyMessage(Message)
已过时.

处理键盘消息。

(继承自 Control)
ProcessKeyPreview(Message)
已过时.

预览键盘消息并返回一个值,该值指示键是否已使用。

ProcessKeyPreview(Message)
已过时.

预览键盘消息。

(继承自 Control)
ProcessMnemonic(Char)
已过时.

处理助记字符。

(继承自 Control)
ProcessTabKey(Keys)
已过时.

获取一个值,该值指示是否应处理 Tab 键。

RaiseDragEvent(Object, DragEventArgs)
已过时.

引发适当的拖动事件。

(继承自 Control)
RaiseKeyEvent(Object, KeyEventArgs)
已过时.

引发相应的键事件。

(继承自 Control)
RaiseMouseEvent(Object, MouseEventArgs)
已过时.

引发相应的鼠标事件。

(继承自 Control)
RaisePaintEvent(Object, PaintEventArgs)
已过时.

引发适当的画图事件。

(继承自 Control)
RecreateHandle()
已过时.

强制重新创建控件的句柄。

(继承自 Control)
RectangleToClient(Rectangle)
已过时.

计算客户端坐标中指定屏幕矩形的大小和位置。

(继承自 Control)
RectangleToScreen(Rectangle)
已过时.

计算屏幕坐标中指定客户端矩形的大小和位置。

(继承自 Control)
Refresh()
已过时.

强制控件使其工作区失效,并立即重新绘制自身和任何子控件。

(继承自 Control)
RescaleConstantsForDpi(Int32, Int32)
已过时.

提供常量,用于在发生 DPI 更改时重新缩放控件。

(继承自 Control)
ResetAlternatingBackColor()
已过时.

AlternatingBackColor 属性重置为其默认颜色。

ResetBackColor()
已过时.

BackColor 属性重置为其默认值。

ResetBackColor()
已过时.

BackColor 属性重置为其默认值。

(继承自 Control)
ResetBindings()
已过时.

使绑定到 BindingSource 控件的控件重新读取列表中的所有项并刷新其显示的值。

(继承自 Control)
ResetCursor()
已过时.

Cursor 属性重置为其默认值。

(继承自 Control)
ResetFont()
已过时.

Font 属性重置为其默认值。

(继承自 Control)
ResetForeColor()
已过时.

ForeColor 属性重置为其默认值。

ResetForeColor()
已过时.

ForeColor 属性重置为其默认值。

(继承自 Control)
ResetGridLineColor()
已过时.

GridLineColor 属性重置为其默认值。

ResetHeaderBackColor()
已过时.

HeaderBackColor 属性重置为其默认值。

ResetHeaderFont()
已过时.

HeaderFont 属性重置为其默认值。

ResetHeaderForeColor()
已过时.

HeaderForeColor 属性重置为其默认值。

ResetImeMode()
已过时.

ImeMode 属性重置为其默认值。

(继承自 Control)
ResetLinkColor()
已过时.

LinkColor 属性重置为其默认值。

ResetLinkHoverColor()
已过时.

LinkHoverColor 属性重置为其默认值。

ResetMouseEventArgs()
已过时.

重置控件以处理 MouseLeave 事件。

(继承自 Control)
ResetRightToLeft()
已过时.

RightToLeft 属性重置为其默认值。

(继承自 Control)
ResetSelection()
已过时.

关闭所选所有行的选择。

ResetSelectionBackColor()
已过时.

SelectionBackColor 属性重置为其默认值。

ResetSelectionForeColor()
已过时.

SelectionForeColor 属性重置为其默认值。

ResetText()
已过时.

Text 属性重置为其默认值(Empty)。

(继承自 Control)
ResumeLayout()
已过时.

恢复通常的布局逻辑。

(继承自 Control)
ResumeLayout(Boolean)
已过时.

恢复通常的布局逻辑,可以选择强制立即布局挂起的布局请求。

(继承自 Control)
RtlTranslateAlignment(ContentAlignment)
已过时.

将指定的 ContentAlignment 值转换为适当的 ContentAlignment 值,以支持从右到左的文本。

(继承自 Control)
RtlTranslateAlignment(HorizontalAlignment)
已过时.

将指定的 HorizontalAlignment 值转换为适当的 HorizontalAlignment 值,以支持从右到左的文本。

(继承自 Control)
RtlTranslateAlignment(LeftRightAlignment)
已过时.

将指定的 LeftRightAlignment 值转换为适当的 LeftRightAlignment 值,以支持从右到左的文本。

(继承自 Control)
RtlTranslateContent(ContentAlignment)
已过时.

将指定的 ContentAlignment 值转换为适当的 ContentAlignment 值,以支持从右到左的文本。

(继承自 Control)
RtlTranslateHorizontal(HorizontalAlignment)
已过时.

将指定的 HorizontalAlignment 值转换为适当的 HorizontalAlignment 值,以支持从右到左的文本。

(继承自 Control)
RtlTranslateLeftRight(LeftRightAlignment)
已过时.

将指定的 LeftRightAlignment 值转换为适当的 LeftRightAlignment 值,以支持从右到左的文本。

(继承自 Control)
Scale(Single, Single)
已过时.
已过时.

缩放整个控件和任何子控件。

(继承自 Control)
Scale(Single)
已过时.
已过时.

缩放控件和任何子控件。

(继承自 Control)
Scale(SizeF)
已过时.

按指定的缩放因子缩放控件和所有子控件。

(继承自 Control)
ScaleBitmapLogicalToDevice(Bitmap)
已过时.

当发生 DPI 更改时,将逻辑位图值缩放为其等效的设备单位值。

(继承自 Control)
ScaleControl(SizeF, BoundsSpecified)
已过时.

缩放控件的位置、大小、填充和边距。

(继承自 Control)
ScaleCore(Single, Single)
已过时.

此方法与此类无关。

(继承自 Control)
Select()
已过时.

激活控件。

(继承自 Control)
Select(Boolean, Boolean)
已过时.

激活子控件。 (可选)指定要从中选择控件的 Tab 键顺序中的方向。

(继承自 Control)
Select(Int32)
已过时.

选择指定的行。

SelectNextControl(Control, Boolean, Boolean, Boolean, Boolean)
已过时.

激活下一个控件。

(继承自 Control)
SendToBack()
已过时.

将控件发送到 z 顺序的后面。

(继承自 Control)
SetAutoSizeMode(AutoSizeMode)
已过时.

设置一个值,该值指示控件在启用控件 AutoSize 属性时的行为方式。

(继承自 Control)
SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)
已过时.

将控件的指定边界设置为指定的位置和大小。

(继承自 Control)
SetBounds(Int32, Int32, Int32, Int32)
已过时.

将控件的边界设置为指定的位置和大小。

(继承自 Control)
SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
已过时.

执行设置此控件的指定边界的工作。

(继承自 Control)
SetClientSizeCore(Int32, Int32)
已过时.

设置控件的工作区的大小。

(继承自 Control)
SetDataBinding(Object, String)
已过时.

DataSource 运行时设置和 DataMember 属性。

SetStyle(ControlStyles, Boolean)
已过时.

将指定的 ControlStyles 标志设置为或 truefalse

(继承自 Control)
SetTopLevel(Boolean)
已过时.

将控件设置为顶级控件。

(继承自 Control)
SetVisibleCore(Boolean)
已过时.

将控件设置为指定的可见状态。

(继承自 Control)
ShouldSerializeAlternatingBackColor()
已过时.

指示是否 AlternatingBackColor 应保留该属性。

ShouldSerializeBackgroundColor()
已过时.

指示是否 BackgroundColor 应保留该属性。

ShouldSerializeCaptionBackColor()
已过时.

获取一个值,该值指示是否应保留该 CaptionBackColor 属性。

ShouldSerializeCaptionForeColor()
已过时.

获取一个值,该值指示是否应保留该 CaptionForeColor 属性。

ShouldSerializeGridLineColor()
已过时.

指示是否 GridLineColor 应保留该属性。

ShouldSerializeHeaderBackColor()
已过时.

指示是否 HeaderBackColor 应保留该属性。

ShouldSerializeHeaderFont()
已过时.

指示是否 HeaderFont 应保留该属性。

ShouldSerializeHeaderForeColor()
已过时.

指示是否 HeaderForeColor 应保留该属性。

ShouldSerializeLinkHoverColor()
已过时.

指示是否 LinkHoverColor 应保留该属性。

ShouldSerializeParentRowsBackColor()
已过时.

指示是否 ParentRowsBackColor 应保留该属性。

ShouldSerializeParentRowsForeColor()
已过时.

指示是否 ParentRowsForeColor 应保留该属性。

ShouldSerializePreferredRowHeight()
已过时.

指示是否 PreferredRowHeight 应保留该属性。

ShouldSerializeSelectionBackColor()
已过时.

指示是否 SelectionBackColor 应保留该属性。

ShouldSerializeSelectionForeColor()
已过时.

指示是否 SelectionForeColor 应保留该属性。

Show()
已过时.

向用户显示控件。

(继承自 Control)
SizeFromClientSize(Size)
已过时.

从工作区的高度和宽度确定整个控件的大小。

(继承自 Control)
SubObjectsSiteChange(Boolean)
已过时.

在与 .DataGrid. 关联的容器中添加或删除DataGridTableStyle对象。

SuspendLayout()
已过时.

暂时挂起控件的布局逻辑。

(继承自 Control)
ToString()
已过时.

返回包含 String 的名称 Component(如果有)。 不应重写此方法。

(继承自 Component)
UnSelect(Int32)
已过时.

取消选择指定的行。

Update()
已过时.

使控件在其工作区内重新绘制无效区域。

(继承自 Control)
UpdateBounds()
已过时.

使用当前大小和位置更新控件的边界。

(继承自 Control)
UpdateBounds(Int32, Int32, Int32, Int32, Int32, Int32)
已过时.

使用指定的大小、位置和客户端大小更新控件的边界。

(继承自 Control)
UpdateBounds(Int32, Int32, Int32, Int32)
已过时.

使用指定的大小和位置更新控件的边界。

(继承自 Control)
UpdateStyles()
已过时.

强制将分配的样式重新应用于控件。

(继承自 Control)
UpdateZOrder()
已过时.

按父级的 z 顺序更新控件。

(继承自 Control)
WndProc(Message)
已过时.

处理 Windows 消息。

(继承自 Control)

活动

名称 说明
AllowNavigationChanged
已过时.

属性 AllowNavigation 已更改时发生。

AutoSizeChanged
已过时.

此事件与此类无关。

(继承自 Control)
BackButtonClick
已过时.

单击子表上的按钮时 Back 发生。

BackColorChanged
已过时.

BackColor 属性的值更改时发生。

(继承自 Control)
BackgroundColorChanged
已过时.

更改 BackgroundColor 后发生。

BackgroundImageChanged
已过时.

BackgroundImage 属性的值更改时发生。

BackgroundImageLayoutChanged
已过时.

BackgroundImageLayout 属性的值更改时发生。

BindingContextChanged
已过时.

BindingContext 属性的值更改时发生。

(继承自 Control)
BorderStyleChanged
已过时.

更改 BorderStyle 后发生。

CaptionVisibleChanged
已过时.

属性 CaptionVisible 已更改时发生。

CausesValidationChanged
已过时.

CausesValidation 属性的值更改时发生。

(继承自 Control)
ChangeUICues
已过时.

焦点或键盘用户界面(UI)提示更改时发生。

(继承自 Control)
Click
已过时.

单击控件时发生。

(继承自 Control)
ClientSizeChanged
已过时.

ClientSize 属性的值更改时发生。

(继承自 Control)
ContextMenuChanged
已过时.

ContextMenu 属性的值更改时发生。

(继承自 Control)
ContextMenuStripChanged
已过时.

ContextMenuStrip 属性的值更改时发生。

(继承自 Control)
ControlAdded
已过时.

将新控件添加到该控件 Control.ControlCollection时发生。

(继承自 Control)
ControlRemoved
已过时.

从中删除 Control.ControlCollection控件时发生 。

(继承自 Control)
CurrentCellChanged
已过时.

属性 CurrentCell 已更改时发生。

CursorChanged
已过时.

Cursor 属性的值更改时发生。

DataContextChanged
已过时.

DataContext 属性的值更改时发生。

(继承自 Control)
DataSourceChanged
已过时.

DataSource 属性值更改后发生。

Disposed
已过时.

当组件通过对方法的调用 Dispose() 释放时发生。

(继承自 Component)
DockChanged
已过时.

Dock 属性的值更改时发生。

(继承自 Control)
DoubleClick
已过时.

双击控件时发生。

(继承自 Control)
DpiChangedAfterParent
已过时.

在控件的父控件或窗体的 DPI 更改后,以编程方式更改控件的 DPI 设置时发生。

(继承自 Control)
DpiChangedBeforeParent
已过时.

在控件的父控件或窗体发生 DPI 更改事件之前,以编程方式更改控件的 DPI 设置时发生。

(继承自 Control)
DragDrop
已过时.

完成拖放操作时发生。

(继承自 Control)
DragEnter
已过时.

当对象被拖动到控件的边界时发生。

(继承自 Control)
DragLeave
已过时.

当对象被拖出控件的边界时发生。

(继承自 Control)
DragOver
已过时.

当对象拖动到控件边界上时发生。

(继承自 Control)
EnabledChanged
已过时.

Enabled 属性值更改后发生。

(继承自 Control)
Enter
已过时.

输入控件时发生。

(继承自 Control)
FlatModeChanged
已过时.

更改 FlatMode 后发生。

FontChanged
已过时.

Font 属性值更改时发生。

(继承自 Control)
ForeColorChanged
已过时.

ForeColor 属性值更改时发生。

(继承自 Control)
GiveFeedback
已过时.

在拖动操作期间发生。

(继承自 Control)
GotFocus
已过时.

当控件收到焦点时发生。

(继承自 Control)
HandleCreated
已过时.

为控件创建句柄时发生。

(继承自 Control)
HandleDestroyed
已过时.

当控件的句柄正在销毁时发生。

(继承自 Control)
HelpRequested
已过时.

当用户请求控件帮助时发生。

(继承自 Control)
ImeModeChanged
已过时.

属性 ImeMode 已更改时发生。

(继承自 Control)
Invalidated
已过时.

当控件的显示需要重绘时发生。

(继承自 Control)
KeyDown
已过时.

当控件具有焦点时按下键时发生。

(继承自 Control)
KeyPress
已过时.

当控件具有焦点时按下字符、空格或反空间键时发生。

(继承自 Control)
KeyUp
已过时.

当控件具有焦点时释放键时发生。

(继承自 Control)
Layout
已过时.

当控件应重新定位其子控件时发生。

(继承自 Control)
Leave
已过时.

当输入焦点离开控件时发生。

(继承自 Control)
LocationChanged
已过时.

Location 属性值更改后发生。

(继承自 Control)
LostFocus
已过时.

当控件失去焦点时发生。

(继承自 Control)
MarginChanged
已过时.

当控件的边距更改时发生。

(继承自 Control)
MouseCaptureChanged
已过时.

当控件失去鼠标捕获时发生。

(继承自 Control)
MouseClick
已过时.

当鼠标单击控件时发生。

(继承自 Control)
MouseDoubleClick
已过时.

在鼠标双击控件时发生。

(继承自 Control)
MouseDown
已过时.

当鼠标指针位于控件上并按下鼠标按钮时发生。

(继承自 Control)
MouseEnter
已过时.

当鼠标指针进入控件时发生。

(继承自 Control)
MouseHover
已过时.

当鼠标指针停留在控件上时发生。

(继承自 Control)
MouseLeave
已过时.

当鼠标指针离开控件时发生。

(继承自 Control)
MouseMove
已过时.

当鼠标指针移到控件上时发生。

(继承自 Control)
MouseUp
已过时.

当鼠标指针位于控件上并释放鼠标按钮时发生。

(继承自 Control)
MouseWheel
已过时.

当鼠标滚轮在控件具有焦点时移动时发生。

(继承自 Control)
Move
已过时.

移动控件时发生。

(继承自 Control)
Navigate
已过时.

当用户导航到新表时发生。

PaddingChanged
已过时.

当控件的填充更改时发生。

(继承自 Control)
Paint
已过时.

重新绘制控件时发生。

(继承自 Control)
ParentChanged
已过时.

Parent 属性值更改时发生。

(继承自 Control)
ParentRowsLabelStyleChanged
已过时.

更改父行的标签样式时发生。

ParentRowsVisibleChanged
已过时.

ParentRowsVisible 属性值更改时发生。

PreviewKeyDown
已过时.

KeyDown 焦点位于此控件上时按下键时,在事件发生之前发生。

(继承自 Control)
QueryAccessibilityHelp
已过时.

在为辅助功能应用程序提供帮助时 AccessibleObject 发生。

(继承自 Control)
QueryContinueDrag
已过时.

在拖放操作期间发生,并使拖动源能够确定是否应取消拖放操作。

(继承自 Control)
ReadOnlyChanged
已过时.

ReadOnly 属性值更改时发生。

RegionChanged
已过时.

Region 属性的值更改时发生。

(继承自 Control)
Resize
已过时.

调整控件大小时发生。

(继承自 Control)
RightToLeftChanged
已过时.

RightToLeft 属性值更改时发生。

(继承自 Control)
RowHeaderClick
已过时.

单击行标题时发生。

Scroll
已过时.

当用户滚动 DataGrid 控件时发生。

ShowParentDetailsButtonClick
已过时.

单击按钮时 ShowParentDetails 发生。

SizeChanged
已过时.

Size 属性值更改时发生。

(继承自 Control)
StyleChanged
已过时.

当控件样式更改时发生。

(继承自 Control)
SystemColorsChanged
已过时.

当系统颜色更改时发生。

(继承自 Control)
TabIndexChanged
已过时.

TabIndex 属性值更改时发生。

(继承自 Control)
TabStopChanged
已过时.

TabStop 属性值更改时发生。

(继承自 Control)
TextChanged
已过时.

Text 属性的值更改时发生。

Validated
已过时.

在控件完成验证时发生。

(继承自 Control)
Validating
已过时.

当控件正在验证时发生。

(继承自 Control)
VisibleChanged
已过时.

Visible 属性值更改时发生。

(继承自 Control)

显式接口实现

名称 说明
IDropTarget.OnDragDrop(DragEventArgs)
已过时.

引发 DragDrop 事件。

(继承自 Control)
IDropTarget.OnDragEnter(DragEventArgs)
已过时.

引发 DragEnter 事件。

(继承自 Control)
IDropTarget.OnDragLeave(EventArgs)
已过时.

引发 DragLeave 事件。

(继承自 Control)
IDropTarget.OnDragOver(DragEventArgs)
已过时.

引发 DragOver 事件。

(继承自 Control)

适用于

另请参阅