ListViewUpdatedEventArgs.AffectedRows プロパティ

定義

更新操作の影響を受けた行の数を取得します。

public:
 property int AffectedRows { int get(); };
public int AffectedRows { get; }
member this.AffectedRows : int
Public ReadOnly Property AffectedRows As Integer

プロパティ値

Int32

更新操作の影響を受けた行の数。

次の例は、プロパティを使用して項目が AffectedRows 更新されたことを確認する方法を示しています。 このコード例は、ListViewUpdatedEventArgs クラスのために提供されている大規模な例の一部です。

void ContactsListView_ItemUpdated(Object sender, ListViewUpdatedEventArgs e)
{
    if (e.Exception != null)
    {
        if (e.AffectedRows == 0)
        {
            e.KeepInEditMode = true;
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify your values and try again.";
        }
        else
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify the values in the recently updated item.";

        e.ExceptionHandled = true;
    }
}
Sub ContactsListView_ItemUpdated(sender As Object, e As ListViewUpdatedEventArgs)
    If e.Exception IsNot Nothing Then
        If e.AffectedRows = 0 Then
            e.KeepInEditMode = True
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify your values and try again."
        Else
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify the values in the recently updated item."
        End If

        e.ExceptionHandled = True
    End If
End Sub

注釈

このプロパティを AffectedRows 使用して、データ ソースから返される更新操作の影響を受けた行の数を決定します。 通常は 1 つの項目のみが更新されるため、このプロパティには通常、0 または 1 の値が含まれます。

更新操作中に、例外を発生させないエラーが発生することがあります。 その場合、プロパティを AffectedRows 使用して項目が更新されたことを確認できます。

適用対象

こちらもご覧ください