473,394 Members | 1,746 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,394 software developers and data experts.

Possible bug with ListViewSubItem foreColor

Has anyone come across the following problem and does anybody know of a
solution.

I am using a ListView to display the age of a collection of items. When the
items are an hour old, I am using the foreColor property to set the color to
Color.Red. Everything is working exactly as expected, except for the
following problem.

In normal use the text gets displayed in the correct color. However if I
cover the control and then uncover it again, the text always gets displayed
in Black. I have checked the foreColor property and it is still showing
Red, even though the text is displayed in black. If I partially cover the
text and then uncover it, half the text is Red and half is Black. The color
is displayed correctly, next time I update the SubItem.Text property

I can only assume that there is a bug in the ListViewSubItem paint function,
called after an Invalidate, which is using the wrong color setting when
painting the control.

Any help on this would be welcome.
Apr 5 '06 #1
1 3108
I had a similar problem, but it was a long time ago and cant remember
the exact fix. I've found my code that works and it was something to
do with having to add the items for the SubItems individually.

I've slightly edited my code but here it is. Hope this helps:

RichS.
ListViewItem lvItem = new ListViewItem(
item.Title, 0 );

lvItem.UseItemStyleForSubItems = false;

if ( true == bOld )
{
lvItem.ImageIndex = 1;
lvItem.ForeColor = SystemColors.GrayText;
}
else
{
lvItem.Font = new Font( lvItem.Font,
lvItem.Font.Style | FontStyle.Bold );
}

lvItem.SubItems.Add( text1, foreColor,
backColor, regularListViewFont );
lvItem.SubItems.Add( text2, foreColor,
darkBackColor, regularListViewFont );
lvItem.SubItems.Add( text3, foreColor,
darkBackColor, boldListViewFont );

Apr 5 '06 #2

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

Similar topics

2
by: Jurgen Oerlemans | last post by:
Hello, I want to change to forecolor of a label. The label is named "lblDevice1" I create a variable called Var Dim Var Var = "lblDevice1" So the next step is: Var.ForeColor =...
5
by: Randal Chapman | last post by:
Hi. I have a custom class which inherits from ListViewItem.ListViewSubItem. It works fine to add new subitems to a listview, but when I try and get them out it tells me that it is an invalid...
9
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to...
0
by: Karsten Sosna | last post by:
Hallo NG, I have a problem with the ListView-Control. I add a ListViewItem(LVI) with a ListViewSubItem(LVSI_Status) to my ListView(ListView1). Then i want to change the the Value of the...
3
by: jcrouse | last post by:
I have the following string: e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0) I want to use the property label.forecolor for my text color. How do I get whats in...
3
by: Chris Calzaretta | last post by:
From: "Chris Calzaretta" <ccalzaretta@hotmail.com> Subject: Re: Is It Possible? Date: Friday, February 04, 2005 11:44 AM Ok i am posting the code I need to create a form from this web service...
0
by: ck.kislay | last post by:
If ,I change the alpha value of forecolor of control like button in VS 2005 then the forecolor didnot show the variation ,forecolor still unchanged while changing the alpha value. I want to show...
0
by: Wolfgrin | last post by:
Hi, I have set up a report In Access 2003 where there are 2 check boxes I refer to to change the color of the Date of that record. That part is working. I also need to Change the color of the...
3
by: Klaudiusz Bryja | last post by:
Hi, I have some problem. I try to get ListViewSubItem type using: Type t = (new Form).GetType().Assembly.GetType("System.Windows.Forms.ListViewItem.ListViewSubItem") but I get t == null. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.