如何使用户无法选择列表框中的前两个项目。我正在尝试使程序在用户更改其选定的索引时运行,但是前两项将成为表的标题,因此如果用户尝试选择它们,我不希望该程序运行。
您可以再次取消选择它们:
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedIndex < 2 Then
If ListBox1.Items.Count < 2 Then
ListBox1.SelectedIndex = -1
Else
ListBox1.SelectedIndex = 2
End If
End If
End Sub
它确实具有-5个优雅点,您可以通过使用ListBox上方的Label或使用ListView来获得这种优雅点。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句