VB.NET - Multi-colored listbox

woklet

Freshman
Joined
Mar 9, 2005
Messages
29
I'm programatically adding items to my listbox in vb.net and would like to change the color of a line to red if its an 'important' item. Does anyone have any code snippets on how to change the color of a particular line in a listbox; or upon adding it if there is a way to set the color?

Any help would be appreciated,
Thanks
Ben
 
This is when intellisense, the object browser, or MSDN could come in handy.

Visual Basic:
YourListItem.BackColor = Color.Red
'OR
YourListItem.ForeColor = Color.Red
 
Thanks for the quick response!

Here is my code...

myListBox.Items.Add("Hello World")
myListBox.Items.Add("Hello World1")
myListBox.Items.Add("Hello World2")
myListBox.Items.Add("Hello World3")

Me.myListBox.Items(1).foreColor = color.Red


Here is the error I get...
An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll

Additional information: Public member 'foreColor' on type 'String' not found.


I know...I'm probably doing something really dumb; but I still can't get it to work. Any thoughts...

Thanks
Ben
 
Ahhh, nevermind...

I just found the listview control. Does everything I need. Thanks anyway though, gang.
 
Back
Top