ColumnDefinitionCollection.Insert(Int32, ColumnDefinition) ColumnDefinitionCollection.Insert(Int32, ColumnDefinition) ColumnDefinitionCollection.Insert(Int32, ColumnDefinition) ColumnDefinitionCollection.Insert(Int32, ColumnDefinition) Method

定義

ColumnDefinition 插入 ColumnDefinitionCollection 內的指定索引位置。Inserts a ColumnDefinition at the specified index position within a ColumnDefinitionCollection.

public:
 virtual void Insert(int index, System::Windows::Controls::ColumnDefinition ^ value);
public void Insert (int index, System.Windows.Controls.ColumnDefinition value);
abstract member Insert : int * System.Windows.Controls.ColumnDefinition -> unit
override this.Insert : int * System.Windows.Controls.ColumnDefinition -> unit
Public Sub Insert (index As Integer, value As ColumnDefinition)

參數

index
Int32 Int32 Int32 Int32

集合內插入項目的位置。The position within the collection where the item is inserted.

實作

例外狀況

範例

下列範例示範如何使用Insert方法來插入ColumnDefinition特定index定位內ColumnDefinitionCollectionThe following example demonstrates how to use the Insert method to insert a ColumnDefinition to a specific index position within a ColumnDefinitionCollection.

private void insertColAt(object sender, RoutedEventArgs e)
{
    colDef1 = new ColumnDefinition();
    grid1.ColumnDefinitions.Insert(grid1.ColumnDefinitions.Count, colDef1);
    tp2.Text = "ColumnDefinition added at index position " + grid1.ColumnDefinitions.IndexOf(colDef1).ToString();
}
Private Sub insertColAt(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim colDef1 As New ColumnDefinition()
    grid1.ColumnDefinitions.Insert(grid1.ColumnDefinitions.Count, colDef1)
    tp2.Text = "ColumnDefinition added at index position " + grid1.ColumnDefinitions.IndexOf(colDef1).ToString()
End Sub

若要檢視完整的範例,請參閱如何: 操作資料行及資料列使用 ColumnDefinitionsCollections 和 rowdefinitionscollections 管理To view the complete sample, see How to: Manipulate Columns and Rows by Using ColumnDefinitionsCollections and RowDefinitionsCollections.

備註

ColumnDefinitionCollection 使用以零為起始的索引編製系統。ColumnDefinitionCollection uses a zero-based indexing system.

適用於

另請參閱