troubleshooting Question

lstbox.selectedindex changed error when cbobox1.selectedvalue = lstbox1.selectedvalue

Avatar of ehanna1
ehanna1 asked on
.NET ProgrammingVisual Basic.NET
8 Comments1 Solution540 ViewsLast Modified:
I have been trying to figure this problem out for a while now. I'm new to programming and i keep getting stuck on this one issue and i cannot or do not know what i am looking for to figure it out.
I have a listbox that is bound to a dataset with multiple tables in the dataset. All objects on the form are bound to differant fields in the dataset except for one, a combobox.
Basically when i select an item in the listbox i want the selectedindex changed event to set the combobox selected value to a column in the listbox selected index but the listbox indexchanged event is still running and it gives an error. It will popup a messagebox with the correct value but the event is not finished firing so it doesn't know what value to assign to the combobox.

the code is
Private Sub lstUserName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstUserName.SelectedIndexChanged

Dim selectrow As DataRow

        Try
            If _loaded = 1 Then

                selectrow = Ds.User.Select("UserID = " & CInt(lstUserName.SelectedValue))(0)
                cbAccessLevel.SelectedValue = selectrow.Item("Column")  '--This is where it blows up

                MessageBox.Show(selectrow.Item("Column").ToString)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            MsgBox(lstUser.SelectedIndex.ToString + " and " + lstUserName.SelectedIndex.ToString)
        End Try

    End Sub
Can someone point me to a good referance??  i think i am just not looking for the right stuff.
ASKER CERTIFIED SOLUTION
John (Yiannis) Toutountzoglou
Instructor Multiengine Pilot

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros