• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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


0
genesisproject
Asked:
genesisproject
  • 2
1 Solution
 
Fox_WhatCommented:
companyList.selected(lngIndex) = True
0
 
dmangCommented:
Looks like you need to iterate through the list..    

 strFind = companyData.Fields("name").Value
With companyList
       For i = 0 To .ListCount - 1
        If strFind = "" Then
           .ListIndex = -1
        Else
           lngpos = SendMessage(.hwnd, _
                                LB_FINDSTRINGEXACT, _
                                i - 1, _
                                ByVal  strFind)
           If lngpos >= 0 Then
              .Selected(lngpos) = True
           End If
        End If
        Next i
    End With
0
 
Fox_WhatCommented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now