System.Data Namespace ConstraintCollection Class
Removes the constraint at the specified index from the collection.
[ VB ]
Public Sub RemoveAt ( _
ByVal index As Integer _
)
[ C# ]
public void RemoveAt (
int index
);
[ C++ ]
public: void RemoveAt (
int index
);
[ JScript ]
public function RemoveAt (
index : int
);
- index
- The index of the Constraint to remove.
The IndexOf method returns the index of a given Constraint.
Use the Contains method to determine if the collection contains the target Constraint.
Use the CanRemove method to determine if a Constraint can be removed.the CollectionChanged event occurs if the removal succeeds.
The following example uses the IndexOf method in conjunction with the RemoveAt method to remove a constraint from the ConstraintCollection.
private void RemoveConstraint ( ConstraintCollection myConstraints,
Constraint myConstraint ) {
try {
if ( myConstraints.Contains ( myConstraint.ConstraintName ) ) {
if ( myConstraints.CanRemove ( myConstraint ) ) {
myConstraints.RemoveAt (
myConstraints.IndexOf ( myConstraint.ConstraintName ) );
}
}
}
catch ( Exception myException ) {
Response.Write ( myException.Message );
}
}
Private Sub RemoveConstraint _
( myConstraints As ConstraintCollection, myConstraint As Constraint )
Try
If myConstraints.Contains ( myConstraint.ConstraintName ) Then
If myConstraints.CanRemove ( myConstraint ) Then
myConstraints.RemoveAt _
( myConstraints.IndexOf ( myConstraint.ConstraintName ) )
End If
End If
Catch myException As Exception
Response.Write ( myException.Message )
End Try
End Sub |
|
C# |
VB |
ConstraintCollection Members CanRemove Contains IndexOf