Reputation: 122
I work on VB.net Compact-framework (VS2008), I use a ComboBox, and I wish to have a function that get the previous SelectedValue
, just before the SelectedValue
changes to the new one (actually changes the DisplayMember
).
Here is a generic example:
Private Sub ComboBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
Dim Bool As Boolean
Bool = MyFunctionClose(ComboBox1.SelectedValueBeforeChange)
...
Bool = MyFunctionOpen(ComboBox1.SelectedValue)
...
End Sub
My question is: Is it possible to catch such ComboBox1.SelectedValueBeforeChange
?
Upvotes: 1
Views: 666
Reputation: 725
just store the SelectedValue
in a variable on the event:
Private cb1PrevValue as object = nothing
Private Sub ComboBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
Dim Bool As Boolean
If cb1PrevValue Is Nothing Then
'cb1PrevValue = DEFAULT_VALUE (Give it a default value for when it is selected the first time)
End If
Bool = MyFunctionClose(cb1PrevValue)
cb1PrevValue = ComboBox1.SelectedValue
...
Bool = MyFunctionOpen(ComboBox1.SelectedValue)
...
End Sub
Upvotes: 1