GridColumnStylesCollection.RemoveAt(Int32) GridColumnStylesCollection.RemoveAt(Int32) GridColumnStylesCollection.RemoveAt(Int32) GridColumnStylesCollection.RemoveAt(Int32) Method

定义

DataGridColumnStyle 中移除具有指定索引的 GridColumnStylesCollectionRemoves the DataGridColumnStyle with the specified index from the GridColumnStylesCollection.

public:
 void RemoveAt(int index);
public void RemoveAt (int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

参数

index
Int32 Int32 Int32 Int32

要移除的 DataGridColumnStyle 的从零开始的索引。The zero-based index of the DataGridColumnStyle to remove.

实现

示例

下面的代码示例使用Contains方法来确定中GridColumnStylesCollection是否存在给定DataGridColumnStyle的。The following code example uses the Contains method to determine if a given DataGridColumnStyle exists in a GridColumnStylesCollection. 如果是这样, IndexOf则该方法将返回的DataGridColumnStyle索引,并Remove通过索引调用方法,以从集合中移除元素。If so, the IndexOf method returns the index of the DataGridColumnStyle, and the Remove method is invoked with the index to remove the element from the collection.

Private Sub RemoveCol(ByVal dc As DataColumn) 
    Dim myGridColumns As GridColumnStylesCollection
    myGridColumns = DataGrid1.TableStyles(0).GridColumnStyles

    If myGridColumns.Contains("FirstName") Then
        Dim i As Integer
        i = myGridColumns.IndexOf(myGridColumns("FirstName"))
        myGridColumns.RemoveAt(i)
    End If
End Sub 

注解

使用方法确定集合中DataGridColumnStyle是否存在。 ContainsUse the Contains method to determine whether the DataGridColumnStyle exists in the collection.

IndexOf使用方法可确定集合中任何元素的索引。Use the IndexOf method to determine the index of any element in the collection.

适用于

另请参阅