DataTable 类

定义

表示内存中数据的一个表。

public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitialize, System::ComponentModel::ISupportInitializeNotification, System::Runtime::Serialization::ISerializable, System::Xml::Serialization::IXmlSerializable
public ref class 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
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
public class DataTable
[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
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitialize
    interface ISupportInitializeNotification
    interface ISerializable
    interface IXmlSerializable
type DataTable = class
[<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
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitialize, ISupportInitializeNotification, IXmlSerializable
Public Class DataTable
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitialize
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitializeNotification, IXmlSerializable
继承
继承
DataTable
派生
属性
实现

示例

以下示例创建两 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 备注

构造函数

DataTable()

在不使用参数的情况下初始化 DataTable 类的新实例。

DataTable(SerializationInfo, StreamingContext)
已过时.

用序列化数据初始化 DataTable 类的新实例。

DataTable(String)

使用指定的表名初始化 DataTable 类的新实例。

DataTable(String, String)

使用指定的表名和命名空间初始化 DataTable 类的新实例。

字段

fInitInProgress

检查是否正在进行初始化。 初始化发生在运行时。

属性

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

获取或设置 ISiteDataTable

TableName

获取或设置 DataTable 的名称。

方法

AcceptChanges()

提交自上次调用 AcceptChanges() 以来对该表进行的所有更改。

BeginInit()

开始初始化在窗体上使用或由另一个组件使用的 DataTable。 初始化发生在运行时。

BeginLoadData()

加载数据时,关闭通知、索引维护和约束。

Clear()

清除所有数据的 DataTable

Clone()

克隆 DataTable 的结构,包括所有 DataTable 架构和约束。

Compute(String, String)

计算用来传递筛选条件的当前行上的给定表达式。

Copy()

复制该 DataTable 的结构和数据。

CreateDataReader()

返回与此 DataTable 内的数据对应的 DataTableReader

CreateInstance()

创建 DataTable 的新实例。

Dispose()

释放由 MarshalByValueComponent 使用的所有资源。

(继承自 MarshalByValueComponent)
Dispose(Boolean)

释放由 MarshalByValueComponent 占用的非托管资源,还可以另外再释放托管资源。

(继承自 MarshalByValueComponent)
EndInit()

结束在窗体上使用或由另一个组件使用的 DataTable 的初始化。 初始化发生在运行时。

EndLoadData()

加载数据后,打开通知、索引维护和约束。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetChanges()

获取 DataTable 的副本,该副本包含自加载以来或自上次调用 AcceptChanges() 以来进行的所有更改。

GetChanges(DataRowState)

获取由 DataRowState 筛选的 DataTable 的副本,该副本包含上次加载以来或调用 AcceptChanges() 以来进行的所有更改。

GetDataTableSchema(XmlSchemaSet)

该方法返回一个包含 Web Services 描述语言 (WSDL) 的 XmlSchemaSet 实例,该语言描述了用于 Web 服务的 DataTable

GetErrors()

获取包含错误的 DataRow 对象数组。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetObjectData(SerializationInfo, StreamingContext)
已过时.

使用序列化 DataTable 时所需的数据填充序列化信息对象。

GetRowType()

获取行类型。

GetSchema()

有关此成员的说明,请参见 GetSchema()

GetService(Type)

获取 IServiceProvider 的实施者。

(继承自 MarshalByValueComponent)
GetType()

获取当前实例的 Type

(继承自 Object)
ImportRow(DataRow)

DataRow 复制到 DataTable 中,保留任何属性设置以及初始值和当前值。

Load(IDataReader)

通过所提供的 IDataReader,用某个数据源的值填充 DataTable。 如果 DataTable 已经包含行,则从数据源传入的数据与现有行合并。

Load(IDataReader, LoadOption)

通过所提供的 IDataReader,用某个数据源的值填充 DataTable。 如果 DataTable 已包含行,则从数据源传入的数据根据 loadOption 参数的值与现有行合并。

Load(IDataReader, LoadOption, FillErrorEventHandler)

通过所提供的使用错误处理委托的 IDataReader,用某个数据源中的值填充 DataTable

LoadDataRow(Object[], Boolean)

查找和更新特定行。 如果找不到任何匹配行,则使用给定值创建新行。

LoadDataRow(Object[], LoadOption)

查找和更新特定行。 如果找不到任何匹配行,则使用给定值创建新行。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Merge(DataTable)

将指定的 DataTable 与当前 DataTable 合并。

Merge(DataTable, Boolean)

将指定的 DataTable 与当前 DataTable 合并,指示是否保留当前 DataTable 中的更改。

Merge(DataTable, Boolean, MissingSchemaAction)

将指定的 DataTable 与当前 DataTable 合并,指示是否保留更改以及如何处理当前 DataTable 中缺失的架构。

NewRow()

创建与该表具有相同架构的新 DataRow

NewRowArray(Int32)

返回 DataRow 的数组。

NewRowFromBuilder(DataRowBuilder)

从现有行创建新行。

OnColumnChanged(DataColumnChangeEventArgs)

引发 ColumnChanged 事件。

OnColumnChanging(DataColumnChangeEventArgs)

引发 ColumnChanging 事件。

OnPropertyChanging(PropertyChangedEventArgs)

引发 PropertyChanged 事件。

OnRemoveColumn(DataColumn)

通知 DataTable 正在移除 DataColumn

OnRowChanged(DataRowChangeEventArgs)

引发 RowChanged 事件。

OnRowChanging(DataRowChangeEventArgs)

引发 RowChanging 事件。

OnRowDeleted(DataRowChangeEventArgs)

引发 RowDeleted 事件。

OnRowDeleting(DataRowChangeEventArgs)

引发 RowDeleting 事件。

OnTableCleared(DataTableClearEventArgs)

引发 TableCleared 事件。

OnTableClearing(DataTableClearEventArgs)

引发 TableClearing 事件。

OnTableNewRow(DataTableNewRowEventArgs)

引发 TableNewRow 事件。

ReadXml(Stream)

使用指定的 Stream 将 XML 架构和数据读入 DataTable

ReadXml(String)

从指定的文件将 XML 架构和数据读入 DataTable

ReadXml(TextReader)

使用指定的 TextReader 将 XML 架构和数据读入 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)

获取由与筛选条件匹配的所有 DataRow 对象组成的数组。

Select(String, String)

以指定排序顺序,获取由与筛选条件匹配的所有 DataRow 对象组成的数组。

Select(String, String, DataViewRowState)

以与指定状态匹配的排序顺序,获取由与筛选条件匹配的所有 DataRow 对象组成的数组。

ToString()

获取 TableNameDisplayExpression(如果有一个用作连接字符串)。

ToString()

返回表示当前对象的字符串。

(继承自 Object)
WriteXml(Stream)

通过指定的 Stream,按 XML 形式编写 DataTable 的当前内容。

WriteXml(Stream, Boolean)

通过指定的 Stream,按 XML 形式编写 DataTable 的当前内容。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(Stream, XmlWriteMode)

使用指定的 XmlWriteModeDataTable 的当前数据和架构(可选)写入指定的文件。 若要写入架构,请将 mode 参数的值设置为 WriteSchema

WriteXml(Stream, XmlWriteMode, Boolean)

使用指定的 XmlWriteModeDataTable 的当前数据和架构(可选)写入指定的文件。 若要写入架构,请将 mode 参数的值设置为 WriteSchema。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(String)

使用指定的文件以 XML 形式写入 DataTable 的当前内容。

WriteXml(String, Boolean)

使用指定的文件以 XML 形式写入 DataTable 的当前内容。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(String, XmlWriteMode)

使用指定的文件和 XmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema

WriteXml(String, XmlWriteMode, Boolean)

使用指定的文件和 XmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(TextWriter)

通过指定的 TextWriter,按 XML 形式编写 DataTable 的当前内容。

WriteXml(TextWriter, Boolean)

通过指定的 TextWriter,按 XML 形式编写 DataTable 的当前内容。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(TextWriter, XmlWriteMode)

使用指定的 TextWriterXmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema

WriteXml(TextWriter, XmlWriteMode, Boolean)

使用指定的 TextWriterXmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXml(XmlWriter)

通过指定的 XmlWriter,按 XML 形式编写 DataTable 的当前内容。

WriteXml(XmlWriter, Boolean)

通过指定的 XmlWriter,按 XML 形式编写 DataTable 的当前内容。

WriteXml(XmlWriter, XmlWriteMode)

使用指定的 XmlWriterXmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema

WriteXml(XmlWriter, XmlWriteMode, Boolean)

使用指定的 XmlWriterXmlWriteMode 写入 DataTable 的当前数据和架构(可选)。 若要写入架构,请将 mode 参数的值设置为 WriteSchema。 若要保存该表及其所有子代的数据,请将 writeHierarchy 参数设置为 true

WriteXmlSchema(Stream)

以 XML 架构的形式将 DataTable 的当前数据结构写入指定的流。

WriteXmlSchema(Stream, Boolean)

以 XML 架构的形式将 DataTable 的当前数据结构写入指定的流。 若要保存该表及其所有子代的架构,请将 writeHierarchy 参数设置为 true

WriteXmlSchema(String)

以 XML 架构的形式将 DataTable 的当前数据结构写入指定的文件。

WriteXmlSchema(String, Boolean)

以 XML 架构的形式将 DataTable 的当前数据结构写入指定的文件。 若要保存该表及其所有子代的架构,请将 writeHierarchy 参数设置为 true

WriteXmlSchema(TextWriter)

使用指定的 TextWriter 以 XML 架构的形式写入 DataTable 的当前数据结构。

WriteXmlSchema(TextWriter, Boolean)

使用指定的 TextWriter 以 XML 架构的形式写入 DataTable 的当前数据结构。 若要保存该表及其所有子代的架构,请将 writeHierarchy 参数设置为 true

WriteXmlSchema(XmlWriter)

使用指定的 XmlWriter 以 XML 架构的形式写入 DataTable 的当前数据结构。

WriteXmlSchema(XmlWriter, Boolean)

使用指定的 XmlWriter 以 XML 架构的形式写入 DataTable 的当前数据结构。 若要保存该表及其所有子代的架构,请将 writeHierarchy 参数设置为 true

事件

ColumnChanged

更改 DataRow 中指定的 DataColumn 值之后发生。

ColumnChanging

更改 DataRow 中指定的 DataColumn 值时发生。

Disposed

添加用于侦听组件的 Disposed 事件的事件处理程序。

(继承自 MarshalByValueComponent)
Initialized

初始化 DataTable 后发生。

RowChanged

在成功更改 DataRow 后发生。

RowChanging

在更改 DataRow 时发生。

RowDeleted

删除表中的行后发生。

RowDeleting

要删除表中的行之前发生。

TableCleared

清除 DataTable 后发生。

TableClearing

清除 DataTable 时发生。

TableNewRow

插入新的 DataRow 时发生。

显式接口实现

IListSource.ContainsListCollection

有关此成员的说明,请参见 ContainsListCollection

IListSource.GetList()

有关此成员的说明,请参见 GetList()

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

使用序列化 DataTable 时所需的数据填充序列化信息对象。

IXmlSerializable.GetSchema()

有关此成员的说明,请参见 GetSchema()

IXmlSerializable.ReadXml(XmlReader)

有关此成员的说明,请参见 ReadXml(XmlReader)

IXmlSerializable.WriteXml(XmlWriter)

有关此成员的说明,请参见 WriteXml(XmlWriter)

扩展方法

AsDataView(DataTable)

创建并返回支持 LINQ 的 DataView 对象。

AsEnumerable(DataTable)

返回一个 IEnumerable<T> 对象,其泛型参数 TDataRow。 此对象可用于 LINQ 表达式或方法查询。

适用于

线程安全性

此类型对于多线程读取操作是安全的。 必须同步所有写入操作。

另请参阅