View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default Deselect Row in ListBox

I have a MultiSelectSingle Listbox and an Edit Button. If the user selects a
line in the listbox it enables the Edit Button and highlights the line blue.
Is there a way to unhighlight the row if it is selected again? I have this
in the Listbox Click Event, but the event won't fire when I select the
highlighted row. Any ideas?

Private Sub lbxPreview_Click()

' load selected part info into controls
With lbxPreview
cboPartNumber = .List(.ListIndex, 0)
tbxQuantity = .List(.ListIndex, 2)
cboBilling = .List(.ListIndex, 4)

' enable or disable Edit button, and deselect listbox
If Not .ListIndex = -1 Then
cmbEditItem.Enabled = True
Else
.Value = Null
cmbEditItem.Enabled = False
End If
End With

' lock or unlock all controls except qty if items is going to be edited
cboPartNumber.Locked = cmbEditItem.Enabled
cboPartDescription.Locked = cmbEditItem.Enabled
cboBilling.Locked = cmbEditItem.Enabled

' only allow quantity to be changed
tbxQuantity.SetFocus

End Sub
--
Cheers,
Ryan