ComboBox: Value after change event.

K

Kevin Hodgson

I have a DataBound ComboBox, which has a text value as the Value property,
and the UniqueID for that value is bound to the Combobox.Tag property.

When a user makes a new selection in the combobox, I need to run a SQL Query
with the UniqueID of the new value they are picking.

The .SelectedIndexChanged and .SelectedValueChanged events give me the .Tag
value BEFORE the new selection is made. I'm getting the value for the
previous value, rather than the new value the user has selected.

What order to the various change events occur, and which one will give me
the new values, as opposed to the old values?
 
A

Anson

Kelvin,

How did you do that? your combo box behaviour is exactly what I wanted!

Anson
 
K

Kevin Hodgson

I didn't do anything special...
Private Sub cmbSelector_SelectedValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles cmbSelector.SelectedValueChanged

Me.DsDataSet1.Clear()
Try
Me.daDataAdapter1.SelectCommand.Parameters.Item("@SelectorID").Value =
Me.cmbSelector.Tag
Me.daDataAdapter1.Fill(Me.DeDataSet1)
Catch ex As Exception
MsgBox(ex.Message)
Application.Exit()
End Try
End Sub



Me.cmbSelector.Text correctly shows the new value, .Tag shows the 'Index' of
the previous value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top