DataTable 類別

定義

代表一個記憶體內資料表。

public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitialize, System::Runtime::Serialization::ISerializable
public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitializeNotification, System::Runtime::Serialization::ISerializable, System::Xml::Serialization::IXmlSerializable
[System.Serializable]
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.Runtime.Serialization.ISerializable
[System.Serializable]
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
[<System.Serializable>]
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitialize
    interface ISerializable
[<System.Serializable>]
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitializeNotification
    interface ISupportInitialize
    interface ISerializable
    interface IXmlSerializable
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitialize
    interface ISupportInitializeNotification
    interface ISerializable
    interface IXmlSerializable
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitialize
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitializeNotification, IXmlSerializable
繼承
衍生
屬性
實作

範例

以下範例會產生兩個 DataTable 物件和一個 DataRelation 物件,並將新的物件加入一個 DataSet。 這些表格會以控制方式顯示 DataGridView

// Put the next line into the Declarations section.
private System.Data.DataSet dataSet;

private void MakeDataTables()
{
    // Run all of the functions.
    MakeParentTable();
    MakeChildTable();
    MakeDataRelation();
    BindToDataGrid();
}

private void MakeParentTable()
{
    // Create a new DataTable.
    System.Data.DataTable table = new DataTable("ParentTable");
    // Declare variables for DataColumn and DataRow objects.
    DataColumn column;
    DataRow row;

    // Create new DataColumn, set DataType,
    // ColumnName and add to DataTable.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "id";
    column.ReadOnly = true;
    column.Unique = true;
    // Add the Column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ParentItem";
    column.AutoIncrement = false;
    column.Caption = "ParentItem";
    column.ReadOnly = false;
    column.Unique = false;
    // Add the column to the table.
    table.Columns.Add(column);

    // Make the ID column the primary key column.
    DataColumn[] PrimaryKeyColumns = new DataColumn[1];
    PrimaryKeyColumns[0] = table.Columns["id"];
    table.PrimaryKey = PrimaryKeyColumns;

    // Instantiate the DataSet variable.
    dataSet = new DataSet();
    // Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table);

    // Create three new DataRow objects and add
    // them to the DataTable
    for (int i = 0; i <= 2; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["ParentItem"] = "ParentItem " + i;
        table.Rows.Add(row);
    }
}

private void MakeChildTable()
{
    // Create a new DataTable.
    DataTable table = new DataTable("childTable");
    DataColumn column;
    DataRow row;

    // Create first column and add to the DataTable.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "ChildID";
    column.AutoIncrement = true;
    column.Caption = "ID";
    column.ReadOnly = true;
    column.Unique = true;

    // Add the column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ChildItem";
    column.AutoIncrement = false;
    column.Caption = "ChildItem";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    // Create third column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "ParentID";
    column.AutoIncrement = false;
    column.Caption = "ParentID";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    dataSet.Tables.Add(table);

    // Create three sets of DataRow objects,
    // five rows each, and add to DataTable.
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 0;
        table.Rows.Add(row);
    }
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i + 5;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 1;
        table.Rows.Add(row);
    }
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i + 10;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 2;
        table.Rows.Add(row);
    }
}

private void MakeDataRelation()
{
    // DataRelation requires two DataColumn
    // (parent and child) and a name.
    DataColumn parentColumn =
        dataSet.Tables["ParentTable"].Columns["id"];
    DataColumn childColumn =
        dataSet.Tables["ChildTable"].Columns["ParentID"];
    DataRelation relation = new
        DataRelation("parent2Child", parentColumn, childColumn);
    dataSet.Tables["ChildTable"].ParentRelations.Add(relation);
}

private void BindToDataGrid()
{
    // Instruct the DataGrid to bind to the DataSet, with the
    // ParentTable as the topmost DataTable.
    DataGrid1.SetDataBinding(dataSet, "ParentTable");
}
' Put the next line into the Declarations section.
private dataSet As DataSet 
 
Private Sub MakeDataTables()
    ' Run all of the functions. 
    MakeParentTable()
    MakeChildTable()
    MakeDataRelation()
    BindToDataGrid()
End Sub
 
Private Sub MakeParentTable()
    ' Create a new DataTable.
    Dim table As New DataTable("ParentTable")

    ' Declare variables for DataColumn and DataRow objects.
    Dim column As DataColumn 
    Dim row As DataRow 
 
    ' Create new DataColumn, set DataType, ColumnName 
    ' and add to DataTable.    
    column = New DataColumn()
    column.DataType = System.Type.GetType("System.Int32")
    column.ColumnName = "id"
    column.ReadOnly = True
    column.Unique = True

    ' Add the Column to the DataColumnCollection.
    table.Columns.Add(column)
 
    ' Create second column.
    column = New DataColumn()
    column.DataType = System.Type.GetType("System.String")
    column.ColumnName = "ParentItem"
    column.AutoIncrement = False
    column.Caption = "ParentItem"
    column.ReadOnly = False
    column.Unique = False

    ' Add the column to the table.
    table.Columns.Add(column)
 
    ' Make the ID column the primary key column.
    Dim PrimaryKeyColumns(0) As DataColumn
    PrimaryKeyColumns(0)= table.Columns("id")
    table.PrimaryKey = PrimaryKeyColumns
 
    ' Instantiate the DataSet variable.
    dataSet = New DataSet()

    ' Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table)
 
    ' Create three new DataRow objects and add 
    ' them to the DataTable
    Dim i As Integer
    For i = 0 to 2
       row = table.NewRow()
       row("id") = i
       row("ParentItem") = "ParentItem " + i.ToString()
       table.Rows.Add(row)
    Next i
End Sub
 
Private Sub MakeChildTable()
    ' Create a new DataTable.
    Dim table As New DataTable("childTable")
    Dim column As DataColumn 
    Dim row As DataRow 
 
    ' Create first column and add to the DataTable.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.Int32")
    column.ColumnName = "ChildID"
    column.AutoIncrement = True
    column.Caption = "ID"
    column.ReadOnly = True
    column.Unique = True

    ' Add the column to the DataColumnCollection.
    table.Columns.Add(column)
 
    ' Create second column.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.String")
    column.ColumnName = "ChildItem"
    column.AutoIncrement = False
    column.Caption = "ChildItem"
    column.ReadOnly = False
    column.Unique = False
    table.Columns.Add(column)
 
    ' Create third column.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.Int32")
    column.ColumnName = "ParentID"
    column.AutoIncrement = False
    column.Caption = "ParentID"
    column.ReadOnly = False
    column.Unique = False
    table.Columns.Add(column)
 
    dataSet.Tables.Add(table)

    ' Create three sets of DataRow objects, five rows each, 
    ' and add to DataTable.
    Dim i As Integer
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 0 
       table.Rows.Add(row)
    Next i
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i + 5
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 1 
       table.Rows.Add(row)
    Next i
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i + 10
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 2 
       table.Rows.Add(row)
    Next i
End Sub
 
Private Sub MakeDataRelation()
    ' DataRelation requires two DataColumn 
    ' (parent and child) and a name.
    Dim parentColumn As DataColumn = _
        dataSet.Tables("ParentTable").Columns("id")
    Dim childColumn As DataColumn = _
        dataSet.Tables("ChildTable").Columns("ParentID")
    Dim relation As DataRelation = new _
        DataRelation("parent2Child", parentColumn, childColumn)
    dataSet.Tables("ChildTable").ParentRelations.Add(relation)
End Sub
 
Private Sub BindToDataGrid()
    ' Instruct the DataGrid to bind to the DataSet, with the 
    ' ParentTable as the topmost DataTable.
    DataGrid1.SetDataBinding(dataSet,"ParentTable")
End Sub

備註

欲了解更多關於此 API 的資訊,請參閱 DataTable 的補充 API 備註

建構函式

名稱 Description
DataTable()

初始化一個無參數的新類別實例 DataTable

DataTable(SerializationInfo, StreamingContext)

使用串行化數據,初始化 DataTable 類別的新實例。

DataTable(String, String)

使用指定的資料表名稱與命名空間初始化該類別的新實例 DataTable

DataTable(String)

初始化一個以指定資料表名稱的新 DataTable 類別實例。

欄位

名稱 Description
fInitInProgress

檢查初始化是否正在進行中。 初始化發生在執行時。

屬性

名稱 Description
CaseSensitive

表示表中字串比較是否區分大小寫。

ChildRelations

為此 DataTable收集兒童關係。

Columns

取得屬於此表的欄位集合。

Constraints

取得由此表維持的約束集合。

Container

取得元件的容器。

(繼承來源 MarshalByValueComponent)
DataSet

DataSet 張桌子該屬於什麼。

DefaultView

會獲得自訂的表格視圖,可能包含過濾檢視或游標位置。

DesignMode

會取得一個值,表示該元件目前是否處於設計模式。

(繼承來源 MarshalByValueComponent)
DisplayExpression

取得或設定一個表達式,回傳用來在使用者介面中表示此表格的值。 這個 DisplayExpression 屬性讓你能在使用者介面中顯示這個資料表的名稱。

Events

取得與此元件相連的事件處理程序清單。

(繼承來源 MarshalByValueComponent)
ExtendedProperties

取得自訂用戶資訊的集合。

HasErrors

會得到一個值,表示該資料表所屬的任一資料表 DataSet 中是否有錯誤。

IsInitialized

會得到一個表示是否 DataTable 已初始化的值。

Locale

取得或設定用於比較表格中字串的地點資訊。

MinimumCapacity

取得或設定此表的初始大小。

Namespace

取得或設定儲存在 DataTable. 中資料的 XML 表示名稱空間。

ParentRelations

取得父 DataTable關係的集合。

Prefix

取得或設定儲存在 DataTable. 中資料的 XML 表示名稱空間。

PrimaryKey

取得或設定一個欄位陣列,作為資料表的主鍵。

RemotingFormat

取得或設定序列化格式。

Rows

取得屬於此表的列集合。

Site

取得或設定 一個 ISite ,為 DataTable

TableName

取得或設定 的名稱。DataTable

方法

名稱 Description
AcceptChanges()

將自上次 AcceptChanges() 呼叫以來所有變更提交到此表。

BeginInit()

開始初始化用於表單或由其他元件使用的 。DataTable 初始化發生在執行時。

BeginLoadData()

在載入資料時關閉通知、索引維護和限制。

Clear()

DataTable清除所有資料。

Clone()

複製 的 DataTable結構,包含所有 DataTable 結構與約束。

Compute(String, String)

計算通過篩選條件的當前列的給定表達式。

Copy()

複製此 DataTable結構與資料。

CreateDataReader()

回傳與此DataTable中資料對應的 aDataTableReader

CreateInstance()

建立一個新的 實例。DataTable

Dispose()

釋放所有由 MarshalByValueComponent.

(繼承來源 MarshalByValueComponent)
Dispose(Boolean)

釋放 未管理的資源, MarshalByValueComponent 並可選擇性地釋放受管理資源。

(繼承來源 MarshalByValueComponent)
EndInit()

結束用於表單或被其他元件使用的 a DataTable 的初始化。 初始化發生在執行時。

EndLoadData()

載入資料後開啟通知、索引維護及限制功能。

Equals(Object)

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

(繼承來源 Object)
GetChanges()

會取得一份包含自載入AcceptChanges()或最後調用以來所有變更的 的DataTable副本。

GetChanges(DataRowState)

會取得一份包含自上次載入或AcceptChanges()被呼叫以來所有變更的副本DataTable,並被 DataRowState過濾。

GetDataTableSchema(XmlSchemaSet)

此方法回傳 XmlSchemaSet 一個包含網路服務描述語言(WSDL)的實例,該語言描述 DataTable 了 for Web Services。

GetErrors()

會得到一個包含錯誤的物件陣列 DataRow

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)

填充序列化資訊物件所需的資料。DataTable

GetRowType()

拿到那種排型。

GetSchema()

關於此成員的描述,請參見 GetSchema()

GetService(Type)

取得 的實作者 IServiceProvider

(繼承來源 MarshalByValueComponent)
GetType()

取得目前實例的 Type

(繼承來源 Object)
ImportRow(DataRow)

將 a DataRow 複製到 DataTable,保留所有屬性設定,以及原始和當前的值。

Load(IDataReader, LoadOption, FillErrorEventHandler)

利用錯誤處理代理所提供的DataTable資料,填IDataReader入資料來源的值。

Load(IDataReader, LoadOption)

利用提供的 DataTable資料來源 來填入 aIDataReader。 若已 DataTable 包含列數,則根據參數值 loadOption ,資料來源的輸入資料會與現有資料列合併。

Load(IDataReader)

利用提供的 DataTable資料來源 來填入 aIDataReader。 如果已經 DataTable 包含資料列,來自資料來源的輸入資料會與現有的資料列合併。

LoadDataRow(Object[], Boolean)

尋找並更新特定一列。 若找不到匹配的列,則會用給定值建立新一列。

LoadDataRow(Object[], LoadOption)

尋找並更新特定一列。 若找不到匹配的列,則會用給定值建立新一列。

MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
Merge(DataTable, Boolean, MissingSchemaAction)

將指定的 DataTable 與目前 DataTable合併,表示是否保留變更,以及如何處理目前 DataTable中缺少的結構。

Merge(DataTable, Boolean)

將指定的 DataTable 與當前 DataTable合併,表示是否保留當前 DataTable的變化。

Merge(DataTable)

將指定的 DataTable 與當前 DataTable合併。

NewRow()

建立 DataRow 一個與表格相同結構的新檔案。

NewRowArray(Int32)

回傳一個陣 DataRow列 。

NewRowFromBuilder(DataRowBuilder)

從現有的列建立一列新資料。

OnColumnChanged(DataColumnChangeEventArgs)

引發 ColumnChanged 事件。

OnColumnChanging(DataColumnChangeEventArgs)

引發 ColumnChanging 事件。

OnPropertyChanging(PropertyChangedEventArgs)

引發 PropertyChanged 事件。

OnRemoveColumn(DataColumn)

通知 DataTable a DataColumn 正在被移除。

OnRowChanged(DataRowChangeEventArgs)

引發 RowChanged 事件。

OnRowChanging(DataRowChangeEventArgs)

引發 RowChanging 事件。

OnRowDeleted(DataRowChangeEventArgs)

引發 RowDeleted 事件。

OnRowDeleting(DataRowChangeEventArgs)

引發 RowDeleting 事件。

OnTableCleared(DataTableClearEventArgs)

引發 TableCleared 事件。

OnTableClearing(DataTableClearEventArgs)

引發 TableClearing 事件。

OnTableNewRow(DataTableNewRowEventArgs)

引發 TableNewRow 事件。

ReadXml(Stream)

利用指定的 StreamXML 結構與資料讀取。DataTable

ReadXml(String)

從指定的檔案讀取 XML 架構和資料。DataTable

ReadXml(TextReader)

利用指定的 TextReaderXML 結構與資料讀取。DataTable

ReadXml(XmlReader)

利用指定的 XmlReader. 將 XML 架構與資料讀取至DataTable

ReadXmlSchema(Stream)

利用指定的串流讀取 XML 架構。DataTable

ReadXmlSchema(String)

從指定檔案讀取 XML 架構 DataTable

ReadXmlSchema(TextReader)

利用指定的 TextReader. 將 XML 結構讀入 DataTable

ReadXmlSchema(XmlReader)

利用指定的 XmlReader. 將 XML 結構讀入 DataTable

ReadXmlSerializable(XmlReader)

讀取 XML 串流。

RejectChanges()

回滾自載入資料表以來所做的所有變更,或上次 AcceptChanges() 呼叫時的變更。

Reset()

將 重置 DataTable 為原始狀態。 重置會移除表格中的所有資料、索引、關係和欄位。 如果資料集包含資料表,該資料表在資料表重置後仍會是資料集的一部分。

Select()

會得到一個包含所有 DataRow 物件的陣列。

Select(String, String, DataViewRowState)

會得到一個陣列,包含所有 DataRow 符合篩選器的物件,依排序順序排列指定狀態。

Select(String, String)

會取得一個包含所有 DataRow 符合篩選條件的物件陣列,依照指定的排序順序排列。

Select(String)

會得到一個包含所有 DataRow 符合篩選條件物件的陣列。

ToString()

若存在一個串接的 1,則得到 TableNameDisplayExpression和 。

WriteXml(Stream, Boolean)

將目前的 內容 DataTable 以指定的 StreamXML 格式寫入。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(Stream, XmlWriteMode, Boolean)

將目前的資料,以及可選的結構 DataTable ,寫入指定檔案,使用指定的 XmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(Stream, XmlWriteMode)

將目前的資料,以及可選的結構 DataTable ,寫入指定檔案,使用指定的 XmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema

WriteXml(Stream)

將目前的 內容 DataTable 以指定的 StreamXML 格式寫入。

WriteXml(String, Boolean)

使用指定檔案將目前的內容 DataTable 寫入為 XML。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(String, XmlWriteMode, Boolean)

利用指定的檔案和XmlWriteMode寫入目前的資料,並可選擇性地寫入結構DataTable。 要撰寫結構,將參數值設 modeWriteSchema。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(String, XmlWriteMode)

利用指定的檔案和XmlWriteMode寫入目前的資料,並可選擇性地寫入結構DataTable。 要撰寫結構,將參數值設 modeWriteSchema

WriteXml(String)

使用指定檔案將目前的內容 DataTable 寫入為 XML。

WriteXml(TextWriter, Boolean)

將目前的 內容 DataTable 以指定的 TextWriterXML 格式寫入。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(TextWriter, XmlWriteMode, Boolean)

會寫入目前的資料,並可選擇性地寫入結構, DataTable 使用指定的 TextWriterXmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(TextWriter, XmlWriteMode)

會寫入目前的資料,並可選擇性地寫入結構, DataTable 使用指定的 TextWriterXmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema

WriteXml(TextWriter)

將目前的 內容 DataTable 以指定的 TextWriterXML 格式寫入。

WriteXml(XmlWriter, Boolean)

將目前的 內容 DataTable 以指定的 XmlWriterXML 格式寫入。

WriteXml(XmlWriter, XmlWriteMode, Boolean)

會寫入目前的資料,並可選擇性地寫入結構, DataTable 使用指定的 XmlWriterXmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema。 要儲存資料表及其所有後代的資料,請將參數設 writeHierarchytrue

WriteXml(XmlWriter, XmlWriteMode)

會寫入目前的資料,並可選擇性地寫入結構, DataTable 使用指定的 XmlWriterXmlWriteMode。 要撰寫結構,將參數值設 modeWriteSchema

WriteXml(XmlWriter)

將目前的 內容 DataTable 以指定的 XmlWriterXML 格式寫入。

WriteXmlSchema(Stream, Boolean)

將目前的資料 DataTable 結構寫入指定的串流,作為 XML 結構。 要保存該資料表及其所有後代的結構,請將參數設 writeHierarchytrue

WriteXmlSchema(Stream)

將目前的資料 DataTable 結構寫入指定的串流,作為 XML 結構。

WriteXmlSchema(String, Boolean)

將目前的資料 DataTable 結構以 XML 架構寫入指定的檔案。 要保存該資料表及其所有後代的結構,請將參數設 writeHierarchytrue

WriteXmlSchema(String)

將目前的資料 DataTable 結構以 XML 架構寫入指定的檔案。

WriteXmlSchema(TextWriter, Boolean)

將目前的資料結構 DataTable 寫入為 XML 結構,使用指定的 TextWriter。 要保存該資料表及其所有後代的結構,請將參數設 writeHierarchytrue

WriteXmlSchema(TextWriter)

將目前的資料結構 DataTable 寫入為 XML 結構,使用指定的 TextWriter

WriteXmlSchema(XmlWriter, Boolean)

將目前的資料結構 DataTable 寫入為 XML 結構,使用指定的 XmlWriter。 要保存該資料表及其所有後代的結構,請將參數設 writeHierarchytrue

WriteXmlSchema(XmlWriter)

將目前的資料結構 DataTable 寫入為 XML 結構,使用指定的 XmlWriter

事件

名稱 Description
ColumnChanged

發生在 中指定DataColumnDataRow值被更改後。

ColumnChanging

當值在 中被更改為指定的DataColumnDataRow值時,會發生。

Disposed

新增一個事件處理器來監聽元件上的事件。Disposed

(繼承來源 MarshalByValueComponent)
Initialized

發生在初始 DataTable 化之後。

RowChanged

發生在 a DataRow 成功更改之後。

RowChanging

當 a DataRow 正在改變時會發生。

RowDeleted

發生在資料表中某一列被刪除之後。

RowDeleting

發生在資料表中某一列即將被刪除之前。

TableCleared

在A DataTable 被清除後發生。

TableClearing

當 a DataTable 被清除時發生。

TableNewRow

當新插入 DataRow 時會發生。

明確介面實作

名稱 Description
IListSource.ContainsListCollection

關於此成員的描述,請參見 ContainsListCollection

IListSource.GetList()

關於此成員的描述,請參見 GetList()

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

填充序列化資訊物件所需的資料。DataTable

IXmlSerializable.GetSchema()

關於此成員的描述,請參見 GetSchema()

IXmlSerializable.ReadXml(XmlReader)

關於此成員的描述,請參見 ReadXml(XmlReader)

IXmlSerializable.WriteXml(XmlWriter)

關於此成員的描述,請參見 WriteXml(XmlWriter)

擴充方法

名稱 Description
AsDataView(DataTable)

建立並回傳一個啟用 LINQ 的 DataView 物件。

AsEnumerable(DataTable)

回傳一個 IEnumerable<T> 物件,其中一般參數 TDataRow。 此物件可用於 LINQ 表達式或方法查詢中。

適用於

執行緒安全性

此類型適合多執行緒讀取操作。 您必須同步處理任何寫入作業。

另請參閱