Reputation: 2967
I have a SelectedIndexChanged event firing when the index in a combobox changes.
I call this from code in a timer, and the user calls it when they select an option.
I cannot figure out how to tell if it was a user action that caused this event to fire or some other event.
I have tried a flag in my timer, which does work but i was looking for a more open solution, that would be more future proof.
Upvotes: 1
Views: 191
Reputation: 2967
I have fixed this by adding event selectionchangecommitted
Private Sub cboGraphType_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles cboGraphType.SelectionChangeCommitted
startStopTimer(True)
End Sub
this then stops the timer, and then the selectionchanged event still fires after this.
but this event stop my timer, which is what i wanted.
Upvotes: 1
Reputation: 5719
About use any flag ...
Dim ByWhat As String
Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick
ByWhat = "TIMER1"
MyJob()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ByWhat = "COMBOBOX1"
MyJob()
End Sub
Sub MyJob()
Select Case ByWhat
Case "TIMER1"
'code if called by timer1
Case "COMBOBOX1"
'code if called by combobox1
End Select
ByWhat = "" '---->Clear it
End Sub
Upvotes: 0