GridColumnStylesCollection.Clear 方法
清除 DataGridColumnStyle 对象的集合。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Sub Clear
用法
Dim instance As GridColumnStylesCollection
instance.Clear
public void Clear ()
public:
void Clear ()
public void Clear ()
public function Clear ()
示例
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
平台
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
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
GridColumnStylesCollection 类
GridColumnStylesCollection 成员
System.Windows.Forms 命名空间
Add