Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub cboTo1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTo1.SelectedIndexChanged
        Dim strUsername As String
        Dim strFullName As String
        Dim ctr As Integer
        Try
            For ctr = 0 To Me.DataGridView2.Rows.Count - 1
                strUsername = Me.DataGridView2.Rows(ctr).Cells(0).Value.ToString.Trim
                strFullName = Me.DataGridView2.Rows(ctr).Cells(1).Value.ToString.Trim      
                If Me.cboTo1.Text = strUsername Then
                    Me.ToolTipCombo.Show(strFullName, Me.cboTo1, 5000)
                End If
            Next
        Catch
        End Try
    End Sub

Please I have about 15 combo boxes populated with usernames. Now, I have the full names of the users

stored in MSSQL database. When you select any username, then it should display the full name

of the selected user. This displays correctly when I select each combobox once. But when I select a

different username in the same combobox, the previously selected username's tooltip rather shows. e.g. For

the first time, I select credible and the tooltip shows "Ben Guff" as full name, and I select powerful,

then "Ben Guff" shows again. Please what could be the problem with code above? Please help. Ben
Posted
Updated 2-Oct-14 8:45am
v2
Comments
Kschuler 2-Oct-14 16:37pm    
Why don't you take a stab at stepping through the problem one more time. You have a DataGridView and you don't talk about it all in your walk through of the problem. Do you have a combobox and then a grid that has many comboboxes? Why is it looping the grid? This method is called for a combobox named cboTOL1...is it called for the comboboxes in the grid as well?
Trak4Net 6-Oct-14 16:34pm    
I don't understand your loop through the datagridview, it looks like you will always get the name that is last in the datagridview. However, typically the SelectionChangeCommitted event is what you want to use instead of SelectedIndexChanged, as usually from my experience the selected item has not committed in the SelectedIndexChanged event, so you will always get the last selected item, not the one you are currently selecting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900