This documentation is archived and is not being maintained.

GridColumnStylesCollection.Remove Method

Removes the specified DataGridColumnStyle from the GridColumnStylesCollection.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public void Remove (
	DataGridColumnStyle column
)
public void Remove (
	DataGridColumnStyle column
)
public function Remove (
	column : DataGridColumnStyle
)
Not applicable.

Parameters

column

The DataGridColumnStyle to remove from the collection.

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

The following code example removes a DataGridColumnStyle from a GridColumnStylesCollection.

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);
   }
}

private void RemoveColumnStyleClicked(Object sender, EventArgs e)
{
    DataGridTableStyle myTableStyle = myDataGrid.get_TableStyles().
        get_Item(0);

    // Get the GridColumnStylesCollection of Data Grid.
    myColumns = myTableStyle.get_GridColumnStyles();
    int i;

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: