No ItemChecked event in a CheckedListBox?

后端 未结 4 1123
故里飘歌
故里飘歌 2020-11-29 08:53

The ListView control has an ItemCheck event which is fired before the item changes, and an ItemChecked event that is fired aft

4条回答
  •  抹茶落季
    2020-11-29 09:57

    Based on Hans Passant's answer I am adding a generic VB.NET version. I needed one method which would be called for all CheckedListBox controls on the form. You can easily tweak this if you need separate methods for each control (adds some redundancy though).

    Public Class Form1
        Delegate Sub ProcessItemCheck(ByRef ListBoxObject As CheckedListBox)
    
        Private Sub ProcessItemCheckSub(ByRef ListBoxObject As CheckedListBox)
            ' Do your actual ItemCheck stuff here
        End Sub
    
        Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
            Dim Objects As Object() = {CheckedListBox1}
            BeginInvoke(New ProcessItemCheck(AddressOf ProcessItemCheckSub), Objects)
        End Sub
    End Class
    

提交回复
热议问题