asp.net.ph

DataTableCollection.RemoveAt Method

System.Data Namespace   DataTableCollection Class


Removes the table at the given index.

[ VB ]
Public Sub RemoveAt ( _
   ByVal index As Integer _
)

[ C# ]
public void RemoveAt (
   int index
);

[ C++ ]
public: void RemoveAt (
   int index
);

[ JScript ]
public function RemoveAt (
   index : int
);

Parameters

index
The index of the table to remove.

Exceptions


Exception Type Condition
ArgumentException The collection does not have a table at the specified index.

Remarks

Use the RemoveAt method to remove the DataTable object at the specified index in the DataTableCollection.

You can also use the Clear method to remove all members of the collection at once.

The CollectionChanged event occurs when a table is successfully removed from the collection.

Example

The following example uses the CanRemove method to test whether the last table in a DataTableCollection can be removed. If so, the RemoveAt method is called to remove the table.

private void RemoveTables ( DataSet ds ) {
   // get the DataTableCollection.
   DataTableCollection myTables = ds.Tables;
   DataTable tbl = myTables [ myTables.Count -1 ];
   if ( myTables.CanRemove ( tbl ) ) myTables.RemoveAt ( myTables.Count -1 );
}
  C# VB

See Also

DataTableCollection Members   Clear   Add Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph