ListViewUpdatedEventArgs.KeepInEditMode 屬性

定義

取得或設定值,這個值表示 ListView 控制項是否在更新作業後停留在編輯模式中。

public:
 property bool KeepInEditMode { bool get(); void set(bool value); };
public bool KeepInEditMode { get; set; }
member this.KeepInEditMode : bool with get, set
Public Property KeepInEditMode As Boolean

屬性值

如果控制項在更新作業後停留在編輯模式中則為 true,否則為 false。 預設為 false

範例

下列範例示範如何在發生例外狀況時,使用 KeepInEditMode 屬性將控制項保留在 ListView 編輯模式中。 此程式碼範例是針對 類別提供的較大範例的 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

備註

根據預設, ListView 控制項會在更新作業之後返回唯讀模式。 將 KeepInEditMode 屬性設定為 true ,以 ListView 指定控制項應該保持編輯模式。 這也會保留使用者輸入的值。

適用於

另請參閱