DataGridTextBoxColumn 類別

定義

TextBox 儲存格中裝載 DataGridColumnStyle 控制項以編輯字串。

public ref class DataGridTextBoxColumn : System::Windows::Forms::DataGridColumnStyle
public class DataGridTextBoxColumn : System.Windows.Forms.DataGridColumnStyle
type DataGridTextBoxColumn = class
    inherit DataGridColumnStyle
Public Class DataGridTextBoxColumn
Inherits DataGridColumnStyle
繼承

範例

下列範例會建立 , DataGridTextBoxColumn 並將其新增至 GridColumnStylesCollectionDataGrid 。 若要執行此程式碼範例,請將它貼到具有 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 包含 DataColumn 的物件,則 DataTypeDataColumn 屬性應該設定為資料類型,以邏輯方式在文字方塊控制項中編輯。 下列資料類型會自動與 :、、、、、 DoubleInt64Int32UInt32UInt64UInt16Int16 、、 SingleString 相關聯。 DecimalDateTimeByteDataGridTextBoxColumn

注意

Visual Basic 不支援下列類型: DateTime 、、 UInt16UInt32UInt64TimeSpan 。 不允許 (運算子。)

建構函式

DataGridTextBoxColumn()

初始化 DataGridTextBoxColumn 類別的新執行個體。

DataGridTextBoxColumn(PropertyDescriptor)

使用指定的 PropertyDescriptor ,初始化 類別的新實例 DataGridTextBoxColumn

DataGridTextBoxColumn(PropertyDescriptor, Boolean)

使用指定的 DataGridTextBoxColumn,初始化 PropertyDescriptor 類別的新執行個體。 指定 DataGridTextBoxColumn 是否為預設的資料行。

DataGridTextBoxColumn(PropertyDescriptor, String)

使用指定的 PropertyDescriptor 和 格式, DataGridTextBoxColumn 初始化 類別的新實例。

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)

使用指定的 DataGridTextBoxColumn 和格式,初始化 PropertyDescriptor 類別的新執行個體。 指定資料行是否為預設資料行。

屬性

Alignment

取得或設定資料行中文字的對齊。

(繼承來源 DataGridColumnStyle)
CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
Container

取得包含 IContainerComponent

(繼承來源 Component)
DataGridTableStyle

取得資料行的 DataGridTableStyle

(繼承來源 DataGridColumnStyle)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
FontHeight

取得資料行字型的高度。

(繼承來源 DataGridColumnStyle)
Format

取得或設定字元,指定如何格式化文字。

FormatInfo

取得或設定特定的文化特性 (Culture) 資訊,用來決定如何格式化數值。

HeaderAccessibleObject

取得資料行的 AccessibleObject

(繼承來源 DataGridColumnStyle)
HeaderText

取得或設定資料行行首的文字。

(繼承來源 DataGridColumnStyle)
MappingName

取得或設定要對應資料行樣式的資料成員名稱。

(繼承來源 DataGridColumnStyle)
NullText

取得或設定當資料行包含 null 時顯示的文字。

(繼承來源 DataGridColumnStyle)
PropertyDescriptor

取得或設定 PropertyDescriptorDataGridTextBoxColumn

ReadOnly

設定數值,表示文字方塊資料行是否為唯讀。

Site

取得或設定 ComponentISite

(繼承來源 Component)
TextBox

取得裝載的 TextBox 控制項。

Width

取得或設定資料行的寬度。

(繼承來源 DataGridColumnStyle)

方法

Abort(Int32)

初始要求以插斷編輯程序。

BeginUpdate()

暫停繪製資料行,直到呼叫 EndUpdate() 方法為止。

(繼承來源 DataGridColumnStyle)
CheckValidDataSource(CurrencyManager)

如果 DataGrid 沒有有效的資料來源,或者這個資料行並未對應至資料來源的有效屬性,則會擲回例外狀況。

(繼承來源 DataGridColumnStyle)
ColumnStartedEditing(Control)

通知 DataGrid 使用者已開始編輯資料行。

(繼承來源 DataGridColumnStyle)
Commit(CurrencyManager, Int32)

初始要求以完成編輯程序。

ConcedeFocus()

通知資料行,正在轉讓焦點。

CreateHeaderAccessibleObject()

取得資料行的 AccessibleObject

(繼承來源 DataGridColumnStyle)
CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
Edit(CurrencyManager, Int32, Rectangle, Boolean)

準備儲存格以進行編輯作業。

(繼承來源 DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

使用指定的 CurrencyManager、資料列編號和 Rectangle 參數準備儲存格以進行編輯作業。

(繼承來源 DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

準備儲存格以進行編輯作業。

EndEdit()

DataGridColumnStyle 結束編輯作業。

EndUpdate()

藉由呼叫 BeginUpdate() 方法繼續繪製暫停的資料行。

(繼承來源 DataGridColumnStyle)
EnterNullValue()

輸入 Value 至資料行。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetColumnValueAtRow(CurrencyManager, Int32)

從指定的 CurrencyManager 取得指定的資料列值。

(繼承來源 DataGridColumnStyle)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetMinimumHeight()

取得在 DataGridColumnStyle 中儲存格的高度。

GetPreferredHeight(Graphics, Object)

取得高度,用於自動重新調整資料行。

GetPreferredSize(Graphics, Object)

傳回在指定資料列 (相對於指定值) 中儲存格的最佳寬度和高度。

GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
HideEditBox()

隱藏 DataGridTextBox 控制項並將焦點 (Focus) 移到 DataGrid 控制項。

InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
Invalidate()

重繪資料行並造成將繪圖訊息傳送至控制項。

(繼承來源 DataGridColumnStyle)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
Paint(Graphics, Rectangle, CurrencyManager, Int32)

繪製 DataGridColumnStyle 成為指定的 GraphicsRectangleCurrencyManager 和資料列編號。

Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)

繪製 DataGridColumnStyle 為指定的 GraphicsRectangleCurrencyManager 和資料列編號和對齊。

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)

繪製 DataGridColumnStyle 為指定的 GraphicsRectangleCurrencyManager 和資料列編號、Brush 和對齊。

PaintText(Graphics, Rectangle, String, Boolean)

在給定的位置,使用指定的對齊方式繪製文字和矩形。

PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean)

使用指定的色彩和對齊方式,在指定的位置上繪製文字和矩形。

ReleaseHostedControl()

移除 DataGrid 編輯資料時對控制項的參考。

ResetHeaderText()

重設 HeaderText 為其預設值 null

(繼承來源 DataGridColumnStyle)
SetColumnValueAtRow(CurrencyManager, Int32, Object)

以指定 CurrencyManager 的值設定指定資料列的值。

(繼承來源 DataGridColumnStyle)
SetDataGrid(DataGrid)

設定這個資料行所屬的 DataGrid 控制項。

(繼承來源 DataGridColumnStyle)
SetDataGridInColumn(DataGrid)

TextBox 控制項加入 DataGrid 控制項的 Control.ControlCollection

ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)
UpdateUI(CurrencyManager, Int32, String)

更新使用者介面。

事件

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)

適用於

另請參閱