In ListBox, I've found that we can not deselect a entry once we selected any one of the entry in the list, even selecting no entry area. But I've found one of the solution to fix this issue as :
Let lstBox be the listbox in a form then,
Private Sub lstBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstBox.MouseDown
Try
If Not lstBox.SelectionMode = SelectionMode.None Then
lstBox.SelectedIndex = lstBox.IndexFromPoint(e.X, e.Y)
End If
If (Windows.Forms.Control.ModifierKeys And Keys.Control) <> 0 Then
If lstBox.SelectedIndex = lstBox.IndexFromPoint(e.X, e.Y) Then
LstbIMBoxList.SelectedIndex = -1
End If
End If
Catch ex As Exception
'
End Try
End Sub
This may fix the issue in many situations depending on the requirements.
No comments:
Post a Comment