RowDefinitionCollection.Insert(Int32, RowDefinition) 方法

定義

RowDefinition 插入 RowDefinitionCollection 內的指定索引位置。

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

參數

index
Int32

集合內插入項目的位置。

value
RowDefinition

要插入的 RowDefinition

實作

例外狀況

index 不是 IList 中的有效索引。

範例

下列範例示範如何使用 Insert 方法,將 插入 RowDefinition 至 內 RowDefinitionCollection 的特定 index 位置。

private void insertRowAt(object sender, RoutedEventArgs e)
{
    rowDef1 = new RowDefinition();
    grid1.RowDefinitions.Insert(grid1.RowDefinitions.Count, rowDef1);
    tp1.Text = "RowDefinition added at index position " + grid1.RowDefinitions.IndexOf(rowDef1).ToString();
}
Private Sub insertRowAt(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim rowDef1 As New RowDefinition
    grid1.RowDefinitions.Insert(grid1.RowDefinitions.Count, rowDef1)
    tp1.Text = "RowDefinition added at index position " + grid1.RowDefinitions.IndexOf(rowDef1).ToString()
End Sub

若要檢視完整的範例,請參閱 如何:使用 ColumnDefinitionsCollections 和 RowDefinitionsCollections 運算元據行和資料列

備註

RowDefinitionCollection 使用以零起始的索引系統。

適用於

另請參閱