NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ColumnsCollection.Remove (Int32)

Removes the column at the specified index from the collection.

[Visual Basic]
Overloads Public Sub Remove( _
   ByVal index As Integer _
)
[C#]
public void Remove(
   int index
);
[C++]
public: void Remove(
   int index
);
[JScript]
public function Remove(
   index : int
);

Parameters

index
The index of the column to remove.

Exceptions

Exception Type Condition
IndexOutOfRangeException The collection doesn't have a column at this index.

Remarks

If the collection is succesfully changed by adding or removing columns, the OnCollectionChanged event occurs.

Example [Visual Basic]

The following example first uses the Contains method to determine if a particular column is found in the collection. If it is found, the CanRemove method tests whether the column can be removed. If so, the column is removed with the Remove method.

[Visual Basic]

Private Sub RemoveColumnAtIndex(thisIndex As Integer)
   Dim cols As ColumnsCollection
   ' Get the ColumnsCollection from a DataTable in a DataSet.
   cols = DataSet1.Tables("Orders").Columns
   If cols.Contains(thisIndex) Then 
      If cols.CanRemove(cols(thisIndex)) Then cols.Remove(thisIndex)
   End If
End If

See Also

ColumnsCollection Class | ColumnsCollection Members | System.Data Namespace | ColumnsCollection.Remove Overload List | IndexOf | Contains | CanRemove