473,401 Members | 2,125 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,401 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 12325
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.