System.Data Namespace ConstraintCollection Class
Removes the constraint, specified by name, from the collection.
[ VB ]
Overloads Public Sub Remove ( _
ByVal name As String _
)
[ C# ]
public void Remove (
String name
);
[ C++ ]
public: void Remove (
String* name
);
[ JScript ]
public function Remove (
name : String
);
- name
- The name of the Constraint to remove.
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 removes a Constraint from a ConstraintCollection after testing for its presence with the Contains method, and whether it can be removed with the CanRemove method.
private void RemoveConstraint ( ConstraintCollection myConstraints,
Constraint myConstraint ) {
try {
if ( myConstraints.Contains ( myConstraint.ConstraintName ) ) {
if ( myConstraints.CanRemove ( myConstraint ) ) {
myConstraints.Remove ( 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.Remove ( myConstraint.ConstraintName )
End If
End If
Catch myException As Exception
Response.Write ( myException.Message )
End Try
End Sub |
|
C# |
VB |
ConstraintCollection Members ConstraintCollection.Remove Overload List CanRemove Contains IndexOf