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
)

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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: