Dışarıya aktar (0) Yazdır
Tümünü Genişlet
EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

DataGridTextBoxColumn Class

Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public class DataGridTextBoxColumn : DataGridColumnStyle
public class DataGridTextBoxColumn extends DataGridColumnStyle
public class DataGridTextBoxColumn extends DataGridColumnStyle
Not applicable.

The DataGridTextBoxColumn class derives from the abstract class DataGridColumnStyle. At run time, the DataGridTextBoxColumn hosts a DataGridTextBox control that allows users to edit text.

Special properties added to the class include Format, and HideEditBox. These properties allow you to access the hosted DataGridTextBox control and its attributes, and set the format for displaying values.

If the data source is a DataTable containing DataColumn objects, the DataType property of the DataColumn should be set to a data type that can logically be edited in a text box control. The following data types are automatically associated with a DataGridTextBoxColumn : Byte, DateTime, Decimal, Double, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, and String.

NoteNote:

The following types are not fully supported by Visual Basic: DateTime, UInt16, UInt32, UInt64, and TimeSpan. (Operators are not allowed.)

The following example creates a DataGridTextBoxColumn is and adds it to the GridColumnStylesCollection. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see Assembly Names.

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.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.DataGridColumnStyle
        System.Windows.Forms.DataGridTextBoxColumn

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Topluluk İçeriği

Ekle
Show:
© 2014 Microsoft