LabelEditEventArgs.CancelEdit 屬性

定義

取得或設定值,表示對 ListViewItem 的標籤所做的變更是否應該取消。

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

屬性值

如果對 ListViewItem 的標籤所做的編輯作業應該取消,則為 true,否則為 false

範例

下列程式碼範例示範如何處理 ListView.BeforeLabelEdit 事件和使用 ItemCancelEdit 屬性。 若要執行此範例,請將下列程式碼貼到包含名為 ListView1 的 ListView 控制項的表單中,並填入至少 3 個專案。 確定所有事件都與其事件處理方法相關聯。

void ListView1_BeforeLabelEdit( Object^ sender,
   System::Windows::Forms::LabelEditEventArgs^ e )
{
   // Allow all but the first two items of the list to 
   // be modified by the user.
   if ( e->Item < 2 )
   {
      e->CancelEdit = true;
   }
}
private void ListView1_BeforeLabelEdit(object sender, 
    System.Windows.Forms.LabelEditEventArgs e)
{
    // Allow all but the first two items of the list to 
    // be modified by the user.
    if (e.Item<2)
    {
        e.CancelEdit = true;
    }
}

Private Sub ListView1_BeforeLabelEdit(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.LabelEditEventArgs) _
    Handles ListView1.BeforeLabelEdit

    ' Allow all but the first two items of the list to be modified by
    ' the user.
    If (e.Item < 2) Then
        e.CancelEdit = True
    End If
End Sub

備註

您可以使用這個屬性來取消 對 卷 ListViewItem 標所做的變更,並將其還原為其原始文字。 使用這個屬性可防止專案的標題變更為不符合應用程式需求的值。

適用於