本文整理汇总了C#中System.Data.DataTableCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DataTableCollection.Add方法的具体用法?C# DataTableCollection.Add怎么用?C# DataTableCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTableCollection
的用法示例。
在下文中一共展示了DataTableCollection.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTables
private void AddTables()
{
// Presuming a DataGrid is displaying more than one table,
// get its DataSet.
DataSet thisDataSet = (DataSet)DataGrid1.DataSource;
for (int i = 0; i < 3; i++)
thisDataSet.Tables.Add();
Console.WriteLine(thisDataSet.Tables.Count.ToString()
+ " tables");
foreach (DataTable table in thisDataSet.Tables)
Console.WriteLine(table.TableName);
}
示例2: AddDataTable
private void AddDataTable()
{
// Get the DataTableCollection of a DataGrid
// control's DataSet.
DataTableCollection tables =
((DataSet)DataGrid1.DataSource).Tables;
// Create a new DataTable.
DataTable table = new DataTable();
// Code to add columns and rows not shown here.
// Add the table to the DataTableCollection.
tables.Add(table);
}
示例3: AddTable
private void AddTable()
{
// Presuming a DataGrid is displaying more than one table,
// get its DataSet.
DataSet thisDataSet = (DataSet)DataGrid1.DataSource;
// Use the Add method to add a new table with a given name.
DataTable table = thisDataSet.Tables.Add("NewTable");
// Code to add columns and rows not shown here.
Console.WriteLine(table.TableName);
Console.WriteLine(thisDataSet.Tables.Count.ToString());
}