Редагувати

Поділитися через


ColumnDefinitionCollection.Insert(Int32, ColumnDefinition) Method

Definition

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)

Parameters

index
Int32

The position within the collection where the item is inserted.

value
ColumnDefinition

The ColumnDefinition 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 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

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

Remarks

ColumnDefinitionCollection uses a zero-based indexing system.

Applies to

See also