GridColumnStylesCollection.Remove(DataGridColumnStyle) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes the specified DataGridColumnStyle from the 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)
Parameters
- column
- DataGridColumnStyle
The DataGridColumnStyle to remove from the collection.
Examples
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
Remarks
Use the Contains method to determine whether the DataGridColumnStyle exists in the collection.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET