Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual Studio 2005 ListBox Item Color

Posted on 2006-04-22
8
Medium Priority
?
277 Views
Last Modified: 2010-08-05
Hi

I have a ListBox with four items.
How do I color the first and third item red instead of the usual black
0
Comment
Question by:Murray Brown
  • 6
  • 2
8 Comments
 
LVL 6

Expert Comment

by:sara110
ID: 16515853
I think this sample will help u
http://www.codeproject.com/cs/combobox/listex.asp
0
 
LVL 6

Expert Comment

by:sara110
ID: 16515871
http://www.dnzone.com/ShowDetail.asp?NewsId=1328  each item with different color
0
 
LVL 6

Expert Comment

by:sara110
ID: 16515874
if u have problem converting these c# code to vb.net let me know
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Murray Brown
ID: 16518149
Hi Sara

I had a problem converting the C# code to vb.net. Please would you tell me a quick way (if there is) to colour one item in a listbox to red. Thanks very much for the help.

Murray
0
 
LVL 6

Expert Comment

by:sara110
ID: 16518500
I have one question, why don't you use LIstview?
with calling this function you could set color for each line
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
0
 
LVL 6

Accepted Solution

by:
sara110 earned 2000 total points
ID: 16518527
the listview control is after combo box control if you are persistent to use listbox, then I should convert that code :-) unless it is easier to use listview
0
 

Author Comment

by:Murray Brown
ID: 16520885
Sara thanks very much for the help. REally appreciate it
0
 
LVL 6

Expert Comment

by:sara110
ID: 16522123
ur welcome :-)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question