473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

change ListBox items color

TF
Hi,
Is there any way to change the text color of SOME of the
ListBox(Windows Forms Control) items in VB.NET?

TF
Jul 21 '05 #1
2 12307
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

"TF" <fa****@coned.com> wrote in message
news:ae**************************@posting.google.c om...
Hi,
Is there any way to change the text color of SOME of the
ListBox(Windows Forms Control) items in VB.NET?

TF

Jul 21 '05 #2
TF
Thanks Anthony

It helped me
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
3
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
3
by: Baren | last post by:
Hi! I have a generalized Stored Procedure to get the listbox items in a datareader.Then i am binding the datareader to the listbox. For different pages and different conditions i need to hide...
2
by: TF | last post by:
Hi, Is there any way to change the text color of SOME of the ListBox(Windows Forms Control) items in VB.NET? TF
2
by: softengg | last post by:
Hi, I have so many items in a listbox (strings such as Apple, Orange, Grapes..etc) and I want to change these to Uppercase and Lower case. Please anybody tell how this is possible in C#.Net ...
1
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
2
by: gnosys | last post by:
In ASP.Net 1.1 using C#, I'm trying to dynamically change the background colors of certain listbox items based on some criteria. For example:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.