This documentation is archived and is not being maintained.

GridColumnStylesCollection.Remove Method

Removes the specified DataGridColumnStyle from the GridColumnStylesCollection.

[Visual Basic]
Public Sub Remove( _
   ByVal column As DataGridColumnStyle _
)
[C#]
public void Remove(
 DataGridColumnStyle column
);
[C++]
public: void Remove(
 DataGridColumnStyle* column
);
[JScript]
public function Remove(
   column : DataGridColumnStyle
);

Parameters

column
The DataGridColumnStyle to remove from the collection.

Remarks

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

Example

[Visual Basic, C#, C++] The following example removes a DataGridColumnStyle from a GridColumnStylesCollection.

[Visual Basic] 
Private Sub RemoveColumnStyle_Clicked(sender As Object, e As EventArgs) Handles removeStyle.Click
   Dim myTableStyle As DataGridTableStyle = myDataGrid.TableStyles(0)
   
   ' Get the GridColumnStylesCollection of Data Grid.
   myColumns = myTableStyle.GridColumnStyles
   Dim i As Integer
   
   ' Remove the CustName ColumnStyle from the data grid.
   If myColumns.Contains("CustName") Then
      Dim myDataColumnStyle As DataGridColumnStyle = myColumns("CustName")
      i = myColumns.IndexOf(myDataColumnStyle)
      myColumns.RemoveAt(i)
   End If
End Sub 'RemoveColumnStyle_Clicked

[C#] 
private void RemoveColumnStyle_Clicked(object sender, EventArgs e)
{
   DataGridTableStyle myTableStyle = myDataGrid.TableStyles[0];

   // Get the GridColumnStylesCollection of Data Grid.
   myColumns = myTableStyle.GridColumnStyles;
   int i;

   // Remove the CustName ColumnStyle from the data grid.
   if(myColumns.Contains("CustName"))
   {
      DataGridColumnStyle myDataColumnStyle= myColumns["CustName"];
      i= myColumns.IndexOf(myDataColumnStyle);
      myColumns.RemoveAt(i);
   }
}

[C++] 
private:
    void RemoveColumnStyle_Clicked(Object* /*sender*/, EventArgs* /*e*/) {
        DataGridTableStyle* myTableStyle = myDataGrid->TableStyles->Item[0];

        // Get the GridColumnStylesCollection of Data Grid.
        myColumns = myTableStyle->GridColumnStyles;
        int i;

        // Remove the CustName ColumnStyle from the data grid.
        if (myColumns->Contains(S"CustName")) {
            DataGridColumnStyle* myDataColumnStyle= myColumns->Item[S"CustName"];
            i= myColumns->IndexOf(myDataColumnStyle);
            myColumns->RemoveAt(i);
        }
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ 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 | DataGridColumnStyle | GridColumnStyles | RemoveAt

Show: