ListViewUpdatedEventArgs.KeepInEditMode Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau menetapkan nilai yang menunjukkan apakah ListView kontrol harus tetap dalam mode edit setelah operasi pembaruan.
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
Nilai Properti
true
jika kontrol harus tetap dalam mode edit setelah operasi pembaruan; jika tidak, false
. Default adalah false
.
Contoh
Contoh berikut menunjukkan cara menggunakan KeepInEditMode properti untuk mempertahankan ListView kontrol dalam mode edit saat pengecualian terjadi. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk ListViewUpdatedEventArgs kelas .
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
Keterangan
Secara default, ListView kontrol kembali ke mode baca-saja setelah operasi pembaruan. Atur KeepInEditMode properti ke true
untuk menentukan bahwa ListView kontrol harus tetap dalam mode edit. Ini juga mempertahankan nilai yang telah dimasukkan pengguna.