Removes the TBD with the specified index from the GridColumnsCollection.
[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 );
Use the IndexOf method to determine the index of any element in the collection.
The following example uses the Contains method to determine if a given TBD exists in a GridColumnsCollection. If so, the IndexOf method returns the index of the DataGridColumn, and the Remove method is invoked with the index to remove the element from the collection.
[Visual Basic]
Private Sub RemoveCol(ByVal dc As DataColumn) Dim dgCols As GridColumnsCollection Set dgCols = DataGrid1.GridColumns If dgCols.Contains(dc) Then Dim i As Integer i = dgCols.IndexOf(dgCols(dc)) ' If it's not the 0-th element in the collection, remove it. If i > 0 Then dgCols.Remove i End If End Sub
GridColumnsCollection Class | GridColumnsCollection Members | System.WinForms Namespace | GridColumnsCollection.Remove Overload List | Add | IndexOf