asp.net.ph

DataColumnCollection.RemoveAt Method

System.Data Namespace   DataColumnCollection Class


Removes the column 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 column to remove.

Exceptions


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

Remarks

Use the RemoveAt method to remove the DataColumn object at the specified index in the DataColumnCollection.

To remove a column with a specified name, use the Remove method. You can also use the Clear method to remove all members of the collection at once.

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

Example

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

private void RemoveColumn ( DataTable myTable ) {
   // get the DataColumnCollection.
   DataColumnCollection myColumns = myTable.Columns;
   DataColumn col = myColumns [ myColumns.Count -1 ];
   if ( myColumns.CanRemove ( col ) ) myColumns.RemoveAt ( myColumns.Count -1 );
}
  C# VB

See Also

DataColumnCollection Members   Add   Clear   Remove 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