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 _
)
[C#]
public void RemoveAt(
 int index
);
[C++]
public: void RemoveAt(
 int index
);
[JScript]
public function RemoveAt(
   index : int
);

Parameters

index
The zero-based index of the DataGridColumnStyle to remove.

Remarks

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.

Example

[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"))
        myGridColumns.RemoveAt(i)
    End If
End Sub 

[JScript] 
function RemoveCol(dc : DataColumn){
  var myGridColumns : GridColumnStylesCollection =
    DataGrid1.TableStyles(0).GridColumnStyles;

  if(myGridColumns.Contains("FirstName")){
    var i = myGridColumns.IndexOf(myGridColumns("FirstName"));
    myGridColumns.RemoveAt(i);
  }
}

[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.

Requirements

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

Show: