SimulateLbColor




'Put a PictureBox named pList on to a Form

Dim pListArr() As String 'Needed
'_________________________________________________________


Private Sub Form_Load()
ReDim pListArr(0) 'Needed & lower bound must be zero
'before adding items to pList

'Make some items

Dim a$(4)
a$(0) = "aaaa"
a$(1) = "bbbb"
a$(2) = "cccc"
a$(3) = "dddd"
a$(4) = "eeee"
'Add items to pseudoListBox

pListADD a$(0), QBColor(0)
pListADD a$(1), QBColor(9)
pListADD a$(2), QBColor(12)
End Sub
'_________________________________________________________


Public Sub pListADD(Item$, Cul&)
'Dim pListArr() As String 'Needed

'ReDim pListArr(0) 'Initialization needed & lower bound must be zero

If UBound(pListArr) = LBound(pListArr) Then pList.Cls 'First item
pListArr(UBound(pListArr)) = Item$
pList.ForeColor = Cul&
pList.Print Item$
ReDim Preserve pListArr(UBound(pListArr) + 1) 'Always 1 extra place in array!
End Sub
'_________________________________________________________


Private Sub pList_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'This routine could just deal with the

'selected item if highlighting not wanted.

'Select item

N = Y \ pList.TextHeight("E") 'LBound(PListArr) MUST = 0
'item is PListArr(N)

'Example: Print item to form

If N < UBound(pListArr) Then Print pListArr(N)
'Highlight line if wanted. Use with pList_MouseUp.

'NB Highlight will spread if Mouse moved while Mouse down!

'Top ypoint of text =

yy = N * pList.TextHeight("E")
pList.DrawMode = 7
pList.Line (0, yy)-(pList.ScaleWidth, yy + pList.TextHeight("E")), pList.BackColor, BF
pList.DrawMode = 13
End Sub
'_________________________________________________________


Private Sub pList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If highlighting not used could also

'just deal with selected item here.

'Select item

N = Y \ pList.TextHeight("E") 'LBound(PListArr) MUST = 0
'item is PListArr(N)

'Remove Highlight

yy = N * pList.TextHeight("E")
pList.DrawMode = 7
pList.Line (0, yy)-(pList.ScaleWidth, yy + pList.TextHeight("E")), pList.BackColor, BF
pList.DrawMode = 13
End Sub











( simulatelbcolor.html )- by Paolo Puglisi - Modifica del 17/12/2023