2009-05-26 14 views

Odpowiedz

21

Impreza ItemCheck jest wyzwalany, gdy sprawdzany stan elementu ma się zmienić, co pozwala zbadać wartość starych i nowych, i aby anulować zmiany, jeśli chcesz (przypisując właściwość nowaWartość z EventArgs parametr). ItemChecked jest wyzwalane po zakończeniu sprawdzania (lub odznaczenia).

przykładowy kod:

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 
}