GridColumnStylesCollection.RemoveAt(Int32) 方法

定义

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

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

示例

下面的代码示例使用 Contains 方法来确定 DataGridColumnStyle 中是否存在给定的 GridColumnStylesCollectionThe 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 

注解

使用 Contains 方法确定 DataGridColumnStyle 集合中是否存在。Use 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.

适用于

另请参阅