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 控件应保持编辑模式。 这还会保留用户输入的值。

适用于

另请参阅