ItemCheckEventArgs.NewValue プロパティ

定義

項目のチェック ボックスをオン、オフ、未確定のいずれかに設定するかどうかを示す値を取得または設定します。

public:
 property System::Windows::Forms::CheckState NewValue { System::Windows::Forms::CheckState get(); void set(System::Windows::Forms::CheckState value); };
public System.Windows.Forms.CheckState NewValue { get; set; }
member this.NewValue : System.Windows.Forms.CheckState with get, set
Public Property NewValue As CheckState

プロパティ値

CheckState 値のいずれか 1 つ。

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの CheckedListBox.ItemCheck 発生を報告します。 このレポートは、イベントが発生したタイミングを知るのに役立ち、デバッグに役立ちます。 複数のイベントまたは頻繁に発生するイベントを報告するには、 を Console.WriteLine に置き換えるかMessageBox.Show、複数行TextBoxにメッセージを追加することを検討してください。

コード例を実行するには、 という名前CheckedListBox1の型CheckedListBoxのインスタンスを含むプロジェクトに貼り付けます。 次に、イベント ハンドラーが イベントに関連付けられていることを確認します CheckedListBox.ItemCheck

private void CheckedListBox1_ItemCheck(Object sender, ItemCheckEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Index", e.Index );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewValue", e.NewValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CurrentValue", e.CurrentValue );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ItemCheck Event" );
}
Private Sub CheckedListBox1_ItemCheck(sender as Object, e as ItemCheckEventArgs) _ 
     Handles CheckedListBox1.ItemCheck

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Index", e.Index)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "NewValue", e.NewValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CurrentValue", e.CurrentValue)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"ItemCheck Event")

End Sub

注釈

このプロパティを使用すると、コントロールによってチェック状態が変更される前に、指定した項目の新しいチェック状態をCheckedListBox確認できます。 新しいチェック状態を決定するだけでなく、イベントのイベント ハンドラーItemCheckでこのプロパティを使用して、指定した状態とは異なるチェック状態に状態を変更できます。 たとえば、ユーザーがアプリケーションの状態に基づいてチェックすべきでないと判断した 内のCheckedListBox項目の横にチェックマークを配置した場合、このプロパティを以前の設定または別のチェック状態に設定することで、チェックマーク状態の変更をオーバーライドできます。

適用対象

こちらもご覧ください