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

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
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
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.

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

lets try something differnet
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
If LstUserName.SelectedIndex>-1 then
 Dim item as object
 Dim index as integer


           item=LstUserName.Selected.item()
           index=LstUserName.Items.IndexOf(item)
       LstUserName.SelectedIndex=index
       cbAccessLevel.SelectedItem=Item

        End If
Random Solutions  
 
programming4us programming4us