By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,980 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,980 IT Pros & Developers. It's quick & easy.

Possible bug with ListViewSubItem foreColor

P: n/a
Has anyone come across the following problem and does anybody know of a

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
Share this Question
Share on Google+
1 Reply

P: n/a
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:

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

lvItem.UseItemStyleForSubItems = false;

if ( true == bOld )
lvItem.ImageIndex = 1;
lvItem.ForeColor = SystemColors.GrayText;
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 discussion thread is closed

Replies have been disabled for this discussion.