This documentation is archived and is not being maintained.

GridColumnStylesCollection.RemoveAt Method

Removes the DataGridColumnStyle with the specified index from the GridColumnStylesCollection.

[Visual Basic]
Public Sub RemoveAt( _
   ByVal index As Integer _
public void RemoveAt(
 int index
public: void RemoveAt(
 int index
public function RemoveAt(
   index : int


The zero-based index of the DataGridColumnStyle to remove.


Use the Contains method to determine whether the DataGridColumnStyle exists in the collection.

Use the IndexOf method to determine the index of any element in the collection.


[Visual Basic, JScript] The following example uses the Contains method to determine if a given DataGridColumnStyle exists in a GridColumnStylesCollection. If so, the IndexOf method returns the index of the DataGridColumnStyle, 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 myGridColumns As GridColumnStylesCollection
    myGridColumns = DataGrid1.TableStyles(0).GridColumnStyles

    If myGridColumns.Contains("FirstName") Then
        Dim i As Integer
        i = myGridColumns.IndexOf(myGridColumns("FirstName"))
    End If
End Sub 

function RemoveCol(dc : DataColumn){
  var myGridColumns : GridColumnStylesCollection =

    var i = myGridColumns.IndexOf(myGridColumns("FirstName"));

[C#, C++] No example is available for C# or C++. To view a Visual Basic or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

GridColumnStylesCollection Class | GridColumnStylesCollection Members | System.Windows.Forms Namespace | Add | IndexOf