GridColumnStylesCollection.Remove(DataGridColumnStyle) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的 DataGridColumnStyle 從 GridColumnStylesCollection 中移除。
public:
void Remove(System::Windows::Forms::DataGridColumnStyle ^ column);
public void Remove (System.Windows.Forms.DataGridColumnStyle column);
member this.Remove : System.Windows.Forms.DataGridColumnStyle -> unit
Public Sub Remove (column As DataGridColumnStyle)
參數
- column
- DataGridColumnStyle
要從集合中移除的 DataGridColumnStyle。
範例
下列程式碼範例會 DataGridColumnStyle 從 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 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 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
備註
Contains使用 方法來判斷 DataGridColumnStyle 是否存在於集合中。