Link to home
Start Free TrialLog in
Avatar of genesisproject
genesisproject

asked on

highlighting information in a listbox

is there a way that i can highlight my old values in a list box

i am loading names from an ini file to an ADODB.Recordset

if my value in my adodb.recordset is set to true then highlight the name in the listbox
this is what I have so far



Set companyData = CC.getCompanyListingFromIniFile(companyData, g_sINIfile)

companyData.MoveFirst

While Not companyData.EOF

     If companyData.Fields("databaseSelected").Value = True Then

         strFind = companyData.Fields("name").Value
          lngindex = SendMessageString(companyList.hwnd, _
                         LB_FINDSTRINGEXACT, _
                         -1, _
                         strFind)
   
     If lngindex > -1 Then
        'I AM TRYING TO HIGHLIGHT EVERY LIST INDEX WITH THE CORRECT NAME BUT NOTHING IS HIGHLIGHTED.
         MYLISTBOX IS SET TO MULTISELECT = 2
        companyList.ListIndex= lngIndex
     
        MsgBox "Item already in List"
    End If

End If

companyData.MoveNext
Wend


Avatar of Fox_What
Fox_What

companyList.selected(lngIndex) = True
ASKER CERTIFIED SOLUTION
Avatar of dmang
dmang
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You only had to change the one line.

No need to iterate through the list, the
return from the sendmessage gave the index
of the item you were looking for. And since
you are iterating through the recordset,
everything would be highlighted.