通过


DataGridTextBoxColumn 类

定义

注意

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

TextBox承载用于编辑字符串的单元格中的DataGridColumnStyle控件。

public ref class DataGridTextBoxColumn : System::Windows::Forms::DataGridColumnStyle
public class DataGridTextBoxColumn : System.Windows.Forms.DataGridColumnStyle
[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 DataGridTextBoxColumn : System.Windows.Forms.DataGridColumnStyle
type DataGridTextBoxColumn = class
    inherit DataGridColumnStyle
[<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 DataGridTextBoxColumn = class
    inherit DataGridColumnStyle
Public Class DataGridTextBoxColumn
Inherits DataGridColumnStyle
继承
属性

示例

以下示例创建一个 DataGridTextBoxColumn 并将其添加到 GridColumnStylesCollection a DataGrid. 若要运行此代码示例,请将其粘贴到具有 DataGrid 命名的 dataGrid1 窗体中,并从构造 Form函数调用它。

private:
   void AddColumn()
   {
      DataTable^ myTable = gcnew DataTable;
      
      // Add a new DataColumn to the DataTable.
      DataColumn^ myColumn = gcnew DataColumn( "myTextBoxColumn" );
      myColumn->DataType = System::Type::GetType( "System::String" );
      myColumn->DefaultValue = "default string";
      myTable->Columns->Add( myColumn );
      
      // Get the CurrencyManager for the DataTable.
      CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
      
      // Use the CurrencyManager to get the PropertyDescriptor for the new column.
      System::ComponentModel::PropertyDescriptor^ pd = cm->GetItemProperties()[ "myTextBoxColumn" ];
      DataGridTextBoxColumn^ myColumnTextColumn;
      
      // Create the DataGridTextBoxColumn with the PropertyDescriptor.
      myColumnTextColumn = gcnew DataGridTextBoxColumn( pd );
      
      // Add the new DataGridColumn to the GridColumnsCollection.
      dataGrid1->DataSource = myTable;
      dataGrid1->TableStyles->Add( gcnew DataGridTableStyle );
      dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumnTextColumn );
   }
private void AddColumn()
{
     DataTable myTable= new DataTable();
 
     // Add a new DataColumn to the DataTable.
     DataColumn myColumn = new DataColumn("myTextBoxColumn");
     myColumn.DataType = System.Type.GetType("System.String");
     myColumn.DefaultValue="default string";
     myTable.Columns.Add(myColumn);
     // Get the CurrencyManager for the DataTable.
     CurrencyManager cm = (CurrencyManager)this.BindingContext[myTable];
     // Use the CurrencyManager to get the PropertyDescriptor for the new column.
     PropertyDescriptor pd = cm.GetItemProperties()["myTextBoxColumn"];
     DataGridTextBoxColumn myColumnTextColumn;
     // Create the DataGridTextBoxColumn with the PropertyDescriptor.
     myColumnTextColumn = new DataGridTextBoxColumn(pd);
     // Add the new DataGridColumn to the GridColumnsCollection.
     dataGrid1.DataSource= myTable;
     dataGrid1.TableStyles.Add(new DataGridTableStyle());
     dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumnTextColumn);
 }
Private Sub AddColumn()
    Dim myTable As New DataTable()
    
    ' Add a new DataColumn to the DataTable.
    Dim myColumn As New DataColumn("myTextBoxColumn")
    myColumn.DataType = System.Type.GetType("System.String")
    myColumn.DefaultValue = "default string"
    myTable.Columns.Add(myColumn)
    ' Get the CurrencyManager for the DataTable.
    Dim cm As CurrencyManager = CType(Me.BindingContext(myTable), CurrencyManager)
    ' Use the CurrencyManager to get the PropertyDescriptor for the new column.
    Dim pd As PropertyDescriptor = cm.GetItemProperties()("myTextBoxColumn")
    Dim myColumnTextColumn As DataGridTextBoxColumn
    ' Create the DataGridTextBoxColumn with the PropertyDescriptor.
    myColumnTextColumn = New DataGridTextBoxColumn(pd)
    ' Add the new DataGridColumn to the GridColumnsCollection.
    dataGrid1.DataSource = myTable
    dataGrid1.TableStyles.Add(New DataGridTableStyle())
    dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumnTextColumn)
End Sub

注解

DataGridTextBoxColumn 派生自 abstractDataGridColumnStyle。 在运行时,托管 DataGridTextBoxColumn 允许用户 DataGridTextBox 编辑文本的控件。

添加到类的特殊属性包括 FormatHideEditBox。 这些属性允许你访问托管 DataGridTextBox 控件及其属性,并设置用于显示值的格式。

如果数据源是DataTable包含对象,DataType则应将数据源的属性DataColumn设置为可在文本框控件中以逻辑方式DataColumn编辑的数据类型。 以下数据类型自动与 a DataGridTextBoxColumn :、、DateTimeDecimalDoubleInt16UInt32UInt16Int64UInt64Int32Single和 。StringByte

注释

Visual Basic 不支持以下类型:DateTime、、UInt16UInt32UInt64TimeSpan。 (不允许使用运算符)。

构造函数

名称 说明
DataGridTextBoxColumn()
已过时.

初始化 DataGridTextBoxColumn 类的新实例。

DataGridTextBoxColumn(PropertyDescriptor, Boolean)
已过时.

使用指定的DataGridTextBoxColumn值初始化类的新实例PropertyDescriptor。 指定该列是否 DataGridTextBoxColumn 为默认列。

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)
已过时.

使用指定的PropertyDescriptor格式初始化类的新实例DataGridTextBoxColumn。 指定列是否为默认列。

DataGridTextBoxColumn(PropertyDescriptor, String)
已过时.

使用指定的PropertyDescriptor和格式初始化类的新实例DataGridTextBoxColumn

DataGridTextBoxColumn(PropertyDescriptor)
已过时.

用指定的PropertyDescriptor值初始化类的新实例DataGridTextBoxColumn

属性

名称 说明
Alignment
已过时.

获取或设置列中文本的对齐方式。

(继承自 DataGridColumnStyle)
CanRaiseEvents
已过时.

获取一个值,该值指示组件是否可以引发事件。

(继承自 Component)
Container
已过时.

IContainer获取包含 .Component

(继承自 Component)
DataGridTableStyle
已过时.

获取 DataGridTableStyle 列。

(继承自 DataGridColumnStyle)
DesignMode
已过时.

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

(继承自 Component)
Events
已过时.

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

(继承自 Component)
FontHeight
已过时.

获取列字体的高度。

(继承自 DataGridColumnStyle)
Format
已过时.

获取或设置指定文本格式的字符(s)。

FormatInfo
已过时.

获取或设置用于确定值格式的区域性特定信息。

HeaderAccessibleObject
已过时.

获取 AccessibleObject 列。

(继承自 DataGridColumnStyle)
HeaderText
已过时.

获取或设置列标题的文本。

(继承自 DataGridColumnStyle)
MappingName
已过时.

获取或设置要映射到的列样式的数据成员的名称。

(继承自 DataGridColumnStyle)
NullText
已过时.

获取或设置列包含 null时显示的文本。

(继承自 DataGridColumnStyle)
PropertyDescriptor
已过时.

获取或设置 .PropertyDescriptorDataGridTextBoxColumn

ReadOnly
已过时.

设置一个值,该值指示文本框列是否为只读。

ReadOnly
已过时.

获取或设置一个值,该值指示是否可以编辑列中的数据。

(继承自 DataGridColumnStyle)
Site
已过时.

获取或设置 ISite .Component

(继承自 Component)
TextBox
已过时.

获取托管 TextBox 控件。

Width
已过时.

获取或设置列的宽度。

(继承自 DataGridColumnStyle)

方法

名称 说明
Abort(Int32)
已过时.

启动中断编辑过程的请求。

BeginUpdate()
已过时.

暂停列的绘制,直到 EndUpdate() 调用该方法。

(继承自 DataGridColumnStyle)
CheckValidDataSource(CurrencyManager)
已过时.

如果没有 DataGrid 有效的数据源,或者此列未映射到数据源中的有效属性,则引发异常。

(继承自 DataGridColumnStyle)
ColumnStartedEditing(Control)
已过时.

通知 DataGrid 用户已开始编辑列。

(继承自 DataGridColumnStyle)
Commit(CurrencyManager, Int32)
已过时.

启动完成编辑过程的请求。

ConcedeFocus()
已过时.

通知列焦点被承认。

ConcedeFocus()
已过时.

通知列,它必须放弃焦点到它所承载的控件。

(继承自 DataGridColumnStyle)
CreateHeaderAccessibleObject()
已过时.

获取 AccessibleObject 列。

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

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

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

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

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

释放由托管资源使用 Component 的非托管资源,并选择性地释放托管资源。

(继承自 Component)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)
已过时.

准备用于编辑的单元格。

Edit(CurrencyManager, Int32, Rectangle, Boolean, String)
已过时.

准备单元格以使用指定的 CurrencyManager行号和 Rectangle 参数进行编辑。

(继承自 DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean)
已过时.

准备用于编辑的单元格。

(继承自 DataGridColumnStyle)
EndEdit()
已过时.

结束对 .. 的 DataGridColumnStyle编辑操作。

EndUpdate()
已过时.

通过调用 BeginUpdate() 该方法恢复挂起的列的绘制。

(继承自 DataGridColumnStyle)
EnterNullValue()
已过时.

在列中输入一个 Value

EnterNullValue()
已过时.

输入列中的 A Value

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

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

(继承自 Object)
GetColumnValueAtRow(CurrencyManager, Int32)
已过时.

从指定的行中获取指定 CurrencyManager行中的值。

(继承自 DataGridColumnStyle)
GetHashCode()
已过时.

用作默认哈希函数。

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

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

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

获取单元格在 . DataGridColumnStyle中的高度。

GetPreferredHeight(Graphics, Object)
已过时.

获取要用于自动调整列大小的高度。

GetPreferredSize(Graphics, Object)
已过时.

返回指定行中相对于指定值的单元格的最佳宽度和高度。

GetService(Type)
已过时.

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

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

获取当前实例的 Type

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

隐藏 DataGridTextBox 控件并将焦点移动到 DataGrid 控件。

InitializeLifetimeService()
已过时.

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

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

重新绘制列并导致绘制消息发送到控件。

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

创建当前 Object的浅表副本。

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

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

(继承自 MarshalByRefObject)
Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)
已过时.

用指定的GraphicsRectangle、行CurrencyManager号和对齐方式绘制一个DataGridColumnStyle

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)
已过时.

绘制具有指定Graphics颜色、RectangleCurrencyManagerBrush和前景色的 ADataGridColumnStyle

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)
已过时.

用指定的GraphicsRectangle、、CurrencyManager行号、背景色、前景色和对齐方式绘制一个DataGridColumnStyle

(继承自 DataGridColumnStyle)
Paint(Graphics, Rectangle, CurrencyManager, Int32)
已过时.

用指定的GraphicsRectangleCurrencyManager号和行号绘制 aDataGridColumnStyle

PaintText(Graphics, Rectangle, String, Boolean)
已过时.

使用指定的对齐方式在给定位置绘制文本和矩形。

PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean)
已过时.

使用指定的颜色和对齐方式在指定位置绘制文本和矩形。

ReleaseHostedControl()
已过时.

删除对用于编辑数据的控件的引用 DataGrid

ReleaseHostedControl()
已过时.

允许列在不需要它托管的控件时释放资源。

(继承自 DataGridColumnStyle)
ResetHeaderText()
已过时.

HeaderText重置其默认值。 null

(继承自 DataGridColumnStyle)
SetColumnValueAtRow(CurrencyManager, Int32, Object)
已过时.

使用指定行中的值设置指定 CurrencyManager行中的值。

(继承自 DataGridColumnStyle)
SetDataGrid(DataGrid)
已过时.

DataGrid设置此列所属的控件。

(继承自 DataGridColumnStyle)
SetDataGridInColumn(DataGrid)
已过时.

向控件DataGridControl.ControlCollection控件添加控件TextBox

SetDataGridInColumn(DataGrid)
已过时.

设置 DataGrid 列。

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

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

(继承自 Component)
UpdateUI(CurrencyManager, Int32, String)
已过时.

更新用户界面。

UpdateUI(CurrencyManager, Int32, String)
已过时.

使用给定文本更新指定行的值。

(继承自 DataGridColumnStyle)

活动

名称 说明
AlignmentChanged
已过时.

Alignment 属性值更改时发生。

(继承自 DataGridColumnStyle)
Disposed
已过时.

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

(继承自 Component)
FontChanged
已过时.

当列的字体更改时发生。

(继承自 DataGridColumnStyle)
HeaderTextChanged
已过时.

HeaderText 属性值更改时发生。

(继承自 DataGridColumnStyle)
MappingNameChanged
已过时.

当值更改时 MappingName 发生。

(继承自 DataGridColumnStyle)
NullTextChanged
已过时.

当值更改时 NullText 发生。

(继承自 DataGridColumnStyle)
PropertyDescriptorChanged
已过时.

PropertyDescriptor 属性值更改时发生。

(继承自 DataGridColumnStyle)
ReadOnlyChanged
已过时.

ReadOnly 属性值更改时发生。

(继承自 DataGridColumnStyle)
WidthChanged
已过时.

Width 属性值更改时发生。

(继承自 DataGridColumnStyle)

显式接口实现

名称 说明
IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control)
已过时.

DataGrid通知控件用户已开始编辑列。

(继承自 DataGridColumnStyle)

适用于

另请参阅