How to Un-highlight listbox

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
 
W

Wayne Morgan

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.
 
W

Wayne Morgan

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.
 
Top