Problem setting color of ListView items

  • Thread starter Thread starter kelvin.koogan
  • Start date Start date
K

kelvin.koogan

Using C++ in VS2005

I am setting color of ListView items (there is only a single column)
using the following code:

ListViewItem ^pItem = gcnew ListViewItem(pName);
pItem->ForeColor = Color::Blue;
this->List->Items->Add(pItem);

But all the items still appear black. If I click on the items with the
mouse then they turn blue.

Any idea what is wrong?

TIA,
KK
 
Using C++ in VS2005

I am setting color of ListView items (there is only a single column)
using the following code:

ListViewItem ^pItem = gcnew ListViewItem(pName);
pItem->ForeColor = Color::Blue;
this->List->Items->Add(pItem);

But all the items still appear black. If I click on the items with the
mouse then they turn blue.

Any idea what is wrong?

I can confirm and expand on this problem.

I have a Listview that is tracing debug output and coloring the lines
(in detail view) according to the category of the message
(Information, Warning, Error, plus several custom categories I use).
Sometimes the colors are used when redrawing the form, sometimes not.
If the window is inactive -- e.g., it is open and has several colored
lines in it, but is not the active window, and I am using another
window that partially covers it -- every redraw uses the correct
colors. As I drag my other application window over it, redraws are
perfect: correct colors are used for every line.

But if the Listview window is the active window, new items are added
using plain black foreground /white background. Also, when the window
becomes the active application, the redraw draws the inactive portions
in black on white instead of using the right colors.

There seem to be more subtleties to the color / bw decision; certain
apps will cause bw redraw when dragged over it, certain not.

I'm going to dig into the Listview source code using Reflector and see
if I can figure out what's up.
 
I can confirm and expand on this problem.

I have a Listview that is tracing debug output and coloring the lines
(in detail view) according to the category of the message
(Information, Warning, Error, plus several custom categories I use).
Sometimes the colors are used when redrawing the form, sometimes not.
If the window is inactive -- e.g., it is open and has several colored
lines in it, but is not the active window, and I am using another
window that partially covers it -- every redraw uses the correct
colors. As I drag my other application window over it, redraws are
perfect: correct colors are used for every line.

But if the Listview window is the active window, new items are added
using plain black foreground /white background. Also, when the window
becomes the active application, the redraw draws the inactive portions
in black on white instead of using the right colors.

There seem to be more subtleties to the color / bw decision; certain
apps will cause bw redraw when dragged over it, certain not.

I'm going to dig into the Listview source code using Reflector and see
if I can figure out what's up.

I got totally lost in the Listview source code.

The problem does *NOT* occur when running the SAME PROGRAM on Windows
2000.
 
Back
Top