473,769 Members | 5,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding text of different colors in listview

VM
Can I add text of different colors to a listview?

Let's say I want to add, on one line, the text "This is my message" on my
listview. Would it be possible to add this sentence to the listview with the
word "This" in one color, "is" in another color, and so on? Then in my next
row, I'd add another sentence with more different colors. Basically, I'd be
changing the text's color dynamically and then adding it to the listview.

Is that possible?
Thanks.
Nov 15 '05 #1
4 2766

Hi VM,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to control the color of different
string parts in one ListView item.
=============== =============== =============== ============
Acutally, .Net WinForm control ListView encapluate the win32 control
List-View, but it does not support this feature of setting.
ListView class does expose this function for developer.

But, I think maybe you can get this done through P/invoke and do custom
draw in Win32 layer.

For more information about custom draw, please refer to the article below:
http://msdn.microsoft.com/library/de...us/shellcc/pla
tform/commctls/custdraw/custdraw.asp

=============== =============== =============== ============
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
Maybe it's a possibility for you to use a DataGrid instead of a ListView.
The following component can do that kind of stuff:
http://dotnet.leadit.be/extendeddatagrid

--
Greetz

Jan Tielens
_______________ _______________ __
Read my weblog: http://weblogs.asp.net/jan
""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:mY******** *****@cpmsftngx a07.phx.gbl...

Hi VM,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to control the color of different
string parts in one ListView item.
=============== =============== =============== ============
Acutally, .Net WinForm control ListView encapluate the win32 control
List-View, but it does not support this feature of setting.
ListView class does expose this function for developer.

But, I think maybe you can get this done through P/invoke and do custom
draw in Win32 layer.

For more information about custom draw, please refer to the article below:
http://msdn.microsoft.com/library/de...us/shellcc/pla tform/commctls/custdraw/custdraw.asp

=============== =============== =============== ============
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
Don't think so. You can change the font and colors of the individual cell
but to my knowledge they behave like textboxes, ie it's all text or no
text that you can change.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode and Nostalgia enabled
Nov 15 '05 #4

Hi VM,

Do you still have any concern?
Please feel free to tell me, I will work with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

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

Similar topics

2
2336
by: RickDee | last post by:
Does anybody know how to display different color text inside ListBox ? I was testing it with CreateGraphics and DrawString methods, but it does not work out. Thanks Regards
1
1962
by: news.microsoft.com | last post by:
When I add to a listview, can the text I have be of different colors? For example, I want to add these two lines to my list view: "This is my program" "This is my other program" Can I add it with "This is" written in red text while "program" is written in yellow text? And then do the same thing with the second line?
0
12290
by: Andrew | last post by:
If item is a ListViewItem and str is a string, why do the following two lines not have the same effect ? item.SubItems.Add(new ListViewItem.ListViewSubItem()).Text = str; item.SubItems.Add(str); In the example code that follows, using the first line (in the ListView constructor) causes the later redisplay of values (to some specified number of decimal places) in the ListView not to work. Using the second line causes
3
2613
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim frm_nc_code As New frm_nc_sen frm_nc_code.Show( Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
20
6676
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in 'frmMain' from 'frmAdd' with the following code: Private Function AddEntry(Title As String, Rating As String, Genre As String, OnLoan As Boolean, ToWho As String)
0
1207
by: sonu | last post by:
Hi all, I have a listview control which has four columns like { Col1, Col2, Col3, Col4}. I add data in listview like this, dim lvitem as listviewItem
0
1317
by: Ken Lameki | last post by:
Hi guys, Needed to know how to display items on a listview and the items on the same listview appear in different colors, say e.g items that need immediate attention are flagged in red for actioning
2
2082
by: colo | last post by:
This is a newbie question... I have a webpage that is showing info from a database using a GridView control. The problem is that I want to color specific Column in different colors. For example... Student Name - Grade - Quartile John - 89 - 1 Lucy - 68 - 3 Mike - 89 - 1
7
3582
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR Me.cboLocation.Text = ""
0
9589
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
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9996
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
8872
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
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
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...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3963
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
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.