Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted

This is when intellisense, the object browser, or MSDN could come in handy.

 

YourListItem.BackColor = Color.Red
'OR
YourListItem.ForeColor = Color.Red

[sIGPIC]e[/sIGPIC]
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...