Freigeben über


GridColumnStylesCollection.Clear-Methode

Löscht die Auflistung von DataGridColumnStyle-Objekten.

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

Syntax

'Declaration
Public Sub Clear
'Usage
Dim instance As GridColumnStylesCollection

instance.Clear
public void Clear ()
public:
void Clear ()
public void Clear ()
public function Clear ()

Beispiel

Private Sub Clear_Clicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearButton.Click
    ' TablesAlreadyAdded set to false so that table styles can be added again.
    TablesAlreadyAdded = False
    myLabel.Text = "All Table Styles Cleared."
    ' Clear all the column styles and also table style for the grid.
    Dim myTableStyle As DataGridTableStyle
    For Each myTableStyle In myDataGrid.TableStyles
        Dim myColumns As GridColumnStylesCollection = myTableStyle.GridColumnStyles
        myColumns.Clear()
    Next myTableStyle
    myDataGrid.TableStyles.Clear()
End Sub 'Clear_Clicked
private void Clear_Clicked(object sender, System.EventArgs e)
{
   // TablesAlreadyAdded set to false so that table styles can be added again.
   TablesAlreadyAdded = false;
   myLabel.Text = "All Table Styles Cleared.";
   // Clear all the column styles and also table style for the grid.
   foreach (DataGridTableStyle myTableStyle in myDataGrid.TableStyles)
   {
      GridColumnStylesCollection myColumns = myTableStyle.GridColumnStyles;
      myColumns.Clear();
   }
   myDataGrid.TableStyles.Clear();
}
private:
   void Clear_Clicked( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // TablesAlreadyAdded set to false so that table styles can be added again.
      TablesAlreadyAdded = false;
      myLabel->Text = "All Table Styles Cleared.";

      // Clear all the column styles and also table style for the grid.
      IEnumerator^ myEnum = myDataGrid->TableStyles->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         DataGridTableStyle^ myTableStyle = safe_cast<DataGridTableStyle^>(myEnum->Current);
         GridColumnStylesCollection^ myColumns = myTableStyle->GridColumnStyles;
         myColumns->Clear();
      }

      myDataGrid->TableStyles->Clear();
   }
private void ClearClicked(Object sender, System.EventArgs e)
{
    // TablesAlreadyAdded set to false so that table styles can be
    // added again.
    TablesAlreadyAdded = false;
    myLabel.set_Text("All Table Styles Cleared.");

    // Clear all the column styles and also table style for the grid.
    for (int iCtr = 0; iCtr < myDataGrid.get_TableStyles().get_Count();
        iCtr++) {
        DataGridTableStyle myTableStyle = myDataGrid.get_TableStyles().
            get_Item(iCtr);
        GridColumnStylesCollection myColumns = myTableStyle.
            get_GridColumnStyles();
        myColumns.Clear();
    }
    myDataGrid.get_TableStyles().Clear();
} //ClearClicked

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

GridColumnStylesCollection-Klasse
GridColumnStylesCollection-Member
System.Windows.Forms-Namespace
Add