How can I unselect the selected item if the user clicks an area that has no items?
The ItemFromPoint property retrieves the index of the item from the cursor. The ColumnFromPoint property gets the index of the column’s header from the cursor. The following sample unselect the last selected item, if the user clicks a section of the control that has no items: Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim i As Long, c As Long Dim b As Boolean b = True With List1 i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c) If (i < 0) Then If (.HeaderVisible) Then c = .ColumnFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY) b = c < 0 End If If (b) Then With .Items If (.SelectCount > 0) Then .SelectItem(.SelectedItem(0)) = False End If End With End If End If End With End Sub The ShowFocusRect property hides the thin rectangle around the focused item. The FocusItem property of Items object gets the index of the focused item.
Related Questions
- When a user clicks a subfolder link in a folder portlet, the content area displays. How can I keep them on the portal page?
- How can we print just a user selected area rather than the whole document, eg from date to date?
- How can I unselect the selected item if the user clicks an area that has no items?