RowDefinitionCollection.IndexOf(RowDefinition) Metoda

Definicja

Zwraca pozycję indeksu danej RowDefinition wartości w obiekcie RowDefinitionCollection.

public:
 virtual int IndexOf(System::Windows::Controls::RowDefinition ^ value);
public int IndexOf (System.Windows.Controls.RowDefinition value);
abstract member IndexOf : System.Windows.Controls.RowDefinition -> int
override this.IndexOf : System.Windows.Controls.RowDefinition -> int
Public Function IndexOf (value As RowDefinition) As Integer

Parametry

value
RowDefinition

Której pozycja indeksu jest wymagana RowDefinition .

Zwraca

Int32

Indeks , jeśli zostanie znaleziony value w kolekcji; w przeciwnym razie - 1.

Implementuje

Przykłady

W poniższym przykładzie pokazano, jak za pomocą IndexOf metody określić położenie indeksu RowDefinition obiektu w obiekcie 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

Aby wyświetlić kompletny przykład, zobacz How to: Manipulate Columns and Rows by Using ColumnDefinitionsCollections and RowDefinitionsCollections (Instrukcje: manipulowanie kolumnami i wierszami przy użyciu kolekcji ColumnDefinitionsCollections i RowDefinitionsCollections).

Dotyczy

Zobacz też