Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Problem setting color of ListView items

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kelvin.koogan@googlemail.com - 30 Jan 2008 13:54 GMT
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
Ross Presser - 30 Jan 2008 16:16 GMT
On Jan 30, 8:54 am, kelvin.koo...@googlemail.com wrote:
> Using C++ in VS2005
>
[quoted text clipped - 9 lines]
>
> 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.
Ross Presser - 30 Jan 2008 17:03 GMT
> On Jan 30, 8:54 am, kelvin.koo...@googlemail.com wrote:
>
[quoted text clipped - 34 lines]
> 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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.