Hi All.
I tried to change color and font for selected ListBox item. For that I used this code, but unfortunately it don't give me result.
How to fix the problem? Thanks
I tried to change color and font for selected ListBox item. For that I used this code, but unfortunately it don't give me result.
Code:
Private Sub YourListBoxName_Click()
Dim i As Integer
For i = 0 To Me.YourListBoxName.ListCount - 1
If Me.YourListBoxName.Selected(i) = True Then
Me.YourListBoxName.ItemData(i) = 1
Me.YourListBoxName.ItemData(i) = RGB(255, 255, 255) ' set font color to white
Me.YourListBoxName.ItemData(i) = RGB(0, 0, 255) ' set background color to blue
Me.YourListBoxName.ItemData(i) = True ' set font to bold
Else
Me.YourListBoxName.ItemData(i) = 0
Me.YourListBoxName.ItemData(i) = RGB(0, 0, 0) ' set font color to black
Me.YourListBoxName.ItemData(i) = RGB(255, 255, 255) ' set background color to white
Me.YourListBoxName.ItemData(i) = False ' set font to regular
End If
Next i
End Sub
How to fix the problem? Thanks