How to Un-highlight listbox

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi

I would like to remove the highlight from the list box after updating it.

When I remove a record from a listbox it moves to the next or previous
record. How do I remove the black highlight.

Thanks in advance
Richard
 
You need to remove the highlight before deleting the record from the
listbox. Get the row or id of the record you want to delete, remove the
highlight (selection), then delete the desired row.
 
Here is an example of a routine that will go through all the entries in a
listbox and deselect them. The highlight will be removed when the entry is
deselected.


On Error GoTo CheckError
Dim i As Integer, strMsg As String
If lstFamilyPosition.ListCount = 0 Then Exit Sub
For i = 0 To lstFamilyPosition.ListCount - 1
lstFamilyPosition.Selected(i) = False
Next i

Cleanup:
Exit Sub

CheckError:
strMsg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox strMsg, vbOKOnly + vbExclamation, "Error", Err.HelpFile,
Err.HelpContext
Resume Cleanup

To deselect a single entry, you need to know its Row Number and set its
Selected property to False.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top