在WinForm中加控件ListBox1(ListBox)。并有如下代码,当事件ListBox1.SelectedIndexChanged发生, Private Sub ABC()被调用。如果我按住向下键不放,ListBox1.SelectedIndex连续变化,ListBox1.SelectedIndexChanged连续发生,Private Sub ABC()被连续调用。问题:我只要最后一个SelectedIndexChanged事件(松开向下键)或选项滚到底( ListBox1.SelectedIndex = 1000 )的时候,Private Sub ABC()才被调用,中间的SelectedIndexChanged事件不调用Private Sub ABC()。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
ListBox1.Items.Clear()
For i = 0 To 1000
ListBox1.Items.Add(i)
Next
ListBox1.SelectedIndex = 0
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
ABC()
End Sub
Private Sub ABC()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
ListBox1.Items.Clear()
For i = 0 To 1000
ListBox1.Items.Add(i)
Next
ListBox1.SelectedIndex = 0
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
ABC()
End Sub
Private Sub ABC()
End Sub