Is it possible to disable(do not want user to select it for some special case) one of the items in a listbox?
Printable View
Is it possible to disable(do not want user to select it for some special case) one of the items in a listbox?
You could put some code in the SelectedIndexChanged() event of the listbox and query the index that the user selected, then allow / disallow selection as needed.
thank you. I will give it a shot.
Hi,
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
With ListBox1
Select Case .SelectedIndex
Case 2, 4
.SelectedIndex = -1
End Select
End With
'Another way ************************
' With ListBox1
' Select Case .SelectedIndex
' Case 2, 4
' .SelectedIndex -= 1
'End Select
'End With
End Sub