In theory, a list box that is set to ReadOnly should display black letters and prevent users from changing the selected item. In practice, it either displays grey letters, or allows users to change the selection, or does both. The solution has been to disable the list box and live with the grey, hard to read letters.
The following subroutine, if called at the beginning of a routine before other processing occurs, will cause a disabled list box to display black letters instead of grey letters, but will block the user from changing the selected item in the list box. In other words, it will look and act like a ReadOnly list box is supposed to look and act, but doesn’t.
Sub JuryRigReadOnlyLst(objLst as Object)
objLst.ReadOnly = True
objLst.Enabled = False
objLst.ReadOnly = False
End Sub
The temptation is to use this in place of
objLst.Enabled = False
but that won’t work. The sub has to be called before other processing.
If your code later enables the list box, you will have to call this sub again before disabling the list box or the disabled list box will revert to displaying grey letters.
This applies to stand-alone list boxes. Disabled list boxes in table controls don’t need this.