I was wondering if it is possible to change lines in a Listbox that have only a certain character in it. For example I have a list of names. I am using Visual Basic 2015
Joe
John
Mike
*Steve
*Tim
Michelle
I would like to make the ones that have the *(or any special character) turn the line Red. I can hard wire in the code exact matches and make it turn red but my listbox will have dynamic information in it so it will be changing all the time. I am marking the information I would like to highlight the information that has the *. Thank you for your time. Here is a small snipet of the generic code I was trying to use.
If ListBox1.Items(e.Index).ToString() = "red.txt" Then
e.Graphics.FillRectangle(Brushes.red, e.Bounds)
End If
e.Graphics.DrawString(ListBox1.Items(e.Index).ToString(), e.Font, Brushes.Black, New System.Drawing.PointF(e.Bounds.X, e.Bounds.Y))
e.DrawFocusRectangle()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…