473,657 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12388
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.Colum ns.Add("Column1 ", 200, HorizontalAlign ment.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.c om> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
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
6501
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 page does not know the items were added client-side.) TIA, Val
3
6096
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 the list back to the database. First of all, I implemented the re-ordering through client-side javascript, which worked great (also it didn't require a postback every time an item was re-ordered). For testing purposes, I'm outputting the contents...
4
11491
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 select, the first one in the listbox is always removed.(The listitem with an index of 0. Box is set to single selection mode) I've looked at multiple examples and they all do it this way. What's wrong? (variables are also being set to the values...
3
2007
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 and show some the items returned by the datareader. Can anyone help me out to solve this issue. Thanks in adavnce.
2
3079
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
9331
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 Thanks in Advance, softengg, UK
1
8302
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 program use. But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is...
1
3663
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" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
11114
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
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.