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

プロパティ値

true ListViewItemのラベルの編集操作を取り消す必要がある場合は 7。それ以外の場合はfalse

次のコード例では、 ListView.BeforeLabelEdit イベントを処理し、 Item プロパティと CancelEdit プロパティを使用する方法を示します。 この例を実行するには、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 のラベルに加えられた変更を取り消し、元のテキストに戻すことができます。 このプロパティを使用して、項目のキャプションがアプリケーションの要件を満たしていない値に変更されないようにします。

適用対象