ConstraintCollection.RemoveAt メソッド
アセンブリ: System.Data (system.data.dll 内)



IndexOf メソッドは、特定の Constraint のインデックスを返します。
RemoveAt メソッドを使用する前に、Contains メソッドを使用して、ターゲットの Constraint がコレクション内に存在するかどうかを確認し、CanRemove メソッドを使用して、Constraint を削除できるかどうかを確認できます。

IndexOf メソッドを RemoveAt メソッドと共に使用して、ConstraintCollection から制約を削除する例を次に示します。
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
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()); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ConstraintCollection.RemoveAt メソッドのページへのリンク