如何编辑ListBox的ListIndex属性?

时间:2018-01-11 00:12:56

标签: vba ms-access

我无法直接更改 ListIndex ,因为它是只读的。

搜索后,我发现了这个

lstEnergieBatiment.Selected(0) = True

会突出显示它,但不会选择它。

我需要编辑属性ListIndex,因为根据用户操作,可能会立即阅读。

我怎样才能做到这一点?

此列表框允许多项选择。

2 个答案:

答案 0 :(得分:1)

您无法编辑listindex。系统设置listindex以指示用户选择了哪个项目。当您处理multiselect时,您更愿意使用它来查看选择了哪些项目:

For i = 0 To LBX.ListCount - 1
    If LBX.Selected(i) Then
    ' whatever

答案 1 :(得分:0)

我会这样做。

Dim Item As Variant
For Each Item In Me.List.ItemsSelected
    Debug.Print Me.List.ItemData(Item)
Next Item