2009-05-26 57 views

答えて

21

ItemCheckイベントがトリガされたときあなたは古いものと新しい値を確認することができ、を変更すること、および必要に応じているEventArgsのNEWVALUEプロパティを割り当てることで(変更をキャンセルする程度である項目のチェック状態パラメータ)。チェック(またはチェックを外す)が完了した後にItemCheckedがトリガーされます。

コードサンプル:

private void ListView_ItemCheck(object sender, ItemCheckEventArgs e) 
{ 
    // the checked state of an item is about to change 
    if (e.NewValue == CheckState.Checked) 
    { 
     // perform some check if this is allowed, and if not... 
     e.NewValue = e.CurrentValue; 
    } 
} 

private void ListView_ItemChecked(object sender, ItemCheckedEventArgs e) 
{ 
    // the checked state of an item has changed 
}