views:

121

answers:

2

When the checked state of a check box change, I would like to know what the new value is. his is what I am doing:

Friend WithEvents clstTask As System.Windows.Forms.CheckedListBox

Private Sub clstTask_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles clstTask.ItemCheck
    Dim SelectedCheckState As CheckState = clstTask.GetItemCheckState(clstTask.SelectedIndex)
End Sub

However, the value of the SelectedCheckState variable is not accuratley reflecting the new state. I think it is showing the current state before the click, as if this were a "Before_CheckChanged" event handler.

The Check box is a 3 state check box, (Checked, UnChecked, Undetermined). Do I have to write ugly code that assumes that if the CheckState returned is state "X" that the CURRENT state must be Y?

+3  A: 

The ItemCheckEventArgs exposes properties CurrentValue and NewValue.

Jon Seigel
Darn. I remember it when I see it. Figured I missed it. Thanks.
Velika
A: 

Check out ItemCheckEventArgs.NewValue and ItemCheckEventArgs.CurrentValue. This is why that parameter is there ;)

tster