TF,
I don't know of an easy way to do it using a ListBox control, I typically do
not use them, I would use a ListView control instead. This typically gives
you more features anyway, not to mention a bit more cosmetic appeal
(strictly my opinion). From what I have discovered using the ListBox
control, you can only set the ForeColor for the entire control, not the
individual items within the control. If you would like to use the ListView
control instead, here some sample code to do what you wanted to do.
Just drag a ListView control onto your form, or build it dynamically,
whichever you prefer, and then add the following code:
Private Sub BuildListView
Dim i As Integer
ListView1.View = View.Details
ListView1.Columns.Add("Column1", 200, HorizontalAlignment.Left)
For i = 0 To 3
Dim x As New ListViewItem
Select Case i
Case 0
x.Text = "Red text goes here..."
x.ForeColor = System.Drawing.Color.Red
Case 1
x.Text = "Blue text goes here..."
x.ForeColor = System.Drawing.Color.Blue
Case 2
x.Text = "Green text goes here..."
x.ForeColor = System.Drawing.Color.Green
Case 3
x.Text = "Black text goes here..."
x.ForeColor = System.Drawing.Color.Black
End Select
ListView1.Items.Add(x)
Next i
End Sub
Hope this helps,
Anthony