ConstraintCollection.RemoveAt(Int32) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Odebere Constraint objekt v zadaném indexu z kolekce.
public:
void RemoveAt(int index);
public void RemoveAt(int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)
Parametry
- index
- Int32
Index odebrání Constraint .
Výjimky
Kolekce nemá v tomto indexu omezení.
Příklady
Následující příklad používá metodu IndexOf společně s metodou RemoveAt k odebrání omezení z ConstraintCollection.
private void RemoveConstraint(ConstraintCollection constraints,
Constraint constraint)
{
try
{
if(constraints.Contains(constraint.ConstraintName))
{
if(constraints.CanRemove(constraint))
{
constraints.RemoveAt(constraints.IndexOf(
constraint.ConstraintName));
}
}
}
catch(Exception e)
{
// Process exception and return.
Console.WriteLine("Exception of type {0} occurred.",
e.GetType());
}
}
Private Sub RemoveConstraint _
(constraints As ConstraintCollection, constraint As Constraint)
Try
If constraints.Contains(constraint.ConstraintName) Then
If constraints.CanRemove(constraint) Then
constraints.RemoveAt _
(constraints.IndexOf(constraint.ConstraintName))
End If
End If
Catch e As Exception
' Process exception and return.
Console.WriteLine("Exception of type {0} occurred.", _
e.GetType().ToString())
End Try
End Sub
Poznámky
Metoda IndexOf vrátí index konkrétního Constraint.
Před použitím RemoveAt metody můžete použít metodu Contains k určení, zda kolekce obsahuje cíl Constrainta CanRemove metoda určit, zda Constraint lze odebrat.
K CollectionChanged události dojde, pokud je omezení úspěšně odebráno.