編輯

共用方式為


RowDefinitionCollection.Insert(Int32, RowDefinition) Method

Definition

Inserts a RowDefinition at the specified index position within a 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)

Parameters

index
Int32

The position within the collection where the item is inserted.

value
RowDefinition

The RowDefinition to insert.

Implements

Exceptions

index is not a valid index in the IList.

Examples

The following example demonstrates how to use the Insert method to insert a RowDefinition to a specific index position within a RowDefinitionCollection.

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

To view the complete sample, see How to: Manipulate Columns and Rows by Using ColumnDefinitionsCollections and RowDefinitionsCollections.

Remarks

RowDefinitionCollection uses a zero-based indexing system.

Applies to

See also