woklet Posted April 25, 2005 Posted April 25, 2005 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 Quote
Leaders snarfblam Posted April 25, 2005 Leaders Posted April 25, 2005 This is when intellisense, the object browser, or MSDN could come in handy. YourListItem.BackColor = Color.Red 'OR YourListItem.ForeColor = Color.Red Quote [sIGPIC]e[/sIGPIC]
woklet Posted April 25, 2005 Author Posted April 25, 2005 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 Quote
woklet Posted April 25, 2005 Author Posted April 25, 2005 Ahhh, nevermind... I just found the listview control. Does everything I need. Thanks anyway though, gang. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.