DataGridTextBoxColumn 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
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 派生自 abstract 类 DataGridColumnStyle。 在运行时,托管 DataGridTextBoxColumn 允许用户 DataGridTextBox 编辑文本的控件。
添加到类的特殊属性包括 Format和 HideEditBox。 这些属性允许你访问托管 DataGridTextBox 控件及其属性,并设置用于显示值的格式。
如果数据源是DataTable包含对象,DataType则应将数据源的属性DataColumn设置为可在文本框控件中以逻辑方式DataColumn编辑的数据类型。 以下数据类型自动与 a DataGridTextBoxColumn :、、DateTime、Decimal、Double、Int16UInt32UInt16Int64UInt64Int32、 Single和 。StringByte
构造函数
| 名称 | 说明 |
|---|---|
| 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 |
已过时.
获取或设置列包含 |
| PropertyDescriptor |
已过时.
|
| ReadOnly |
已过时.
设置一个值,该值指示文本框列是否为只读。 |
| ReadOnly |
已过时.
获取或设置一个值,该值指示是否可以编辑列中的数据。 (继承自 DataGridColumnStyle) |
| Site |
已过时.
(继承自 Component)
|
| TextBox |
已过时.
获取托管 TextBox 控件。 |
| Width |
已过时.
获取或设置列的宽度。 (继承自 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) |