DataGridTextBoxColumn (Clase)
Actualización: noviembre 2007
Aloja un control TextBox en una celda de DataGridColumnStyle para editar cadenas.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
La clase DataGridTextBoxColumn se deriva de la clase abstractDataGridColumnStyle. En tiempo de ejecución, DataGridTextBoxColumn aloja un control DataGridTextBox que permite a los usuarios editar texto.
Entre las propiedades especiales que se agregan a la clase se incluyen Format y HideEditBox. Estas propiedades permiten tener acceso al control DataGridTextBox alojado y sus atributos, y establecer el formato en que se mostrarán los valores.
Si el origen de datos es un objeto DataTable que contiene objetos DataColumn, la propiedad DataType de DataColumn debe establecerse en un tipo de datos que pueda editarse de manera lógica en un control de cuadro de texto. Los siguientes tipos de datos se asocian automáticamente a DataGridTextBoxColumn: Byte, DateTime, Decimal, Double, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single y String.
vb#En el ejemplo siguiente se crea un objeto DataGridTextBoxColumn y se agrega a GridColumnStylesCollection. Para que este código de ejemplo se ejecute, debe proporcionar el nombre completo del ensamblado. Para obtener información sobre la forma de obtener el nombre de ensamblado completo, vea Nombres de ensamblado.
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 void AddColumn()
{
DataTable myTable = new DataTable();
// Add a new DataColumn to the DataTable.
DataColumn myColumn = new DataColumn("myTextBoxColumn");
myColumn.set_DataType(System.Type.GetType("System.String"));
myColumn.set_DefaultValue("default string");
myTable.get_Columns().Add(myColumn);
// Get the CurrencyManager for the DataTable.
CurrencyManager cm = (CurrencyManager)(this.get_BindingContext().
get_Item(myTable));
// Use the CurrencyManager to get the PropertyDescriptor
// for the new column.
PropertyDescriptor pd = cm.GetItemProperties().
get_Item("myTextBoxColumn");
DataGridTextBoxColumn myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor.
myColumnTextColumn = new DataGridTextBoxColumn(pd);
// Add the new DataGridColumn to the GridColumnsCollection.
dataGrid1.set_DataSource(myTable);
dataGrid1.get_TableStyles().Add(new DataGridTableStyle());
dataGrid1.get_TableStyles().get_Item(0).
get_GridColumnStyles().Add(myColumnTextColumn);
} //AddColumn
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.DataGridColumnStyle
System.Windows.Forms.DataGridTextBoxColumn
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Nota: