GridColumnStylesCollection.Remove(DataGridColumnStyle) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
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。
示例
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 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 。