DataRow.Table 属性
定义
public:
property System::Data::DataTable ^ Table { System::Data::DataTable ^ get(); };
public System.Data.DataTable Table { get; }
member this.Table : System.Data.DataTable
Public ReadOnly Property Table As DataTable
属性值
该行所属的 DataTable。The DataTable to which this row belongs.
示例
下面的示例使用 Table 属性返回对的列集合的引用 DataTable 。The following example uses the Table property to return a reference to the columns collection of the DataTable.
private void GetTable(DataRow row)
{
// Get the DataTable of a DataRow
DataTable table = row.Table;
// Print the DataType of each column in the table.
foreach(DataColumn column in table.Columns)
{
Console.WriteLine(column.DataType);
}
}
Private Sub GetTable(ByVal row As DataRow)
' Get the DataTable of a DataRow
Dim table As DataTable = row.Table
' Print the DataType of each column in the table.
Dim column As DataColumn
For Each column in table.Columns
Console.WriteLine(column.DataType)
Next
End Sub
注解
不 DataRow 一定属于任何表的行集合。A DataRow does not necessarily belong to any table's collection of rows. 如果已 DataRow 创建但未添加到中,则会发生此行为 DataRowCollection 。This behavior occurs when the DataRow has been created but not added to the DataRowCollection. 如果 RowState 属性返回 DataRowState.Detached
,则该行不在任何集合中。If the RowState property returns DataRowState.Detached
, the row is not in any collection.