Listview item and color

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

In a list view with various columns with numbers, I would like to give
a few numbers a different color. I would be happy to know how can it
be done.

Many thanks.
 
You can use the ListViewItem.ListViewSubItem Properties:

ListView listView;
ListViewItem item = new ListViewItem("Test");
item.UseItemStyleForSubItems = false;
item.SubItems.Add("Text", cForeColor, cBackColor, fFont);
...

Or have a look here:
http://www.codeproject.com/cs/miscctrl/aa_listview.asp
I think I followed a different approach. Like so

ListViewItem list = new ListViewItem (show)
ListView1.Items.Add(list)

I have this code in a loop. During each iteration
I fill the show array with new values.

Now in some cases I would like to colour items
and would like to know how to do this in line
with the above coding.

(I did find your article very interesting though.)
 
Perhaps I don´t understand you...

Do you want something like this:

0 1 2 3
----------|----------|----------|----------|
Text1 Black Green Blue
Text2 Black Green Blue
Text3 Black Green Blue
Text4 Black Green Blue

If this is not what you want you have to explain it once again ;-)
Greetings, timtos.
 
If you want something like this you omit some information.
How do you add the subitems? In the loop you showed me,
only the main items were added. And what exactly is "show"?

If you like to you can send me a minimized test application, so
that I can have a look at the code myself.

Sorry for not being able to help at the moment,
timtos.
 
If you like to you can send me a minimized test application, so
that I can have a look at the code myself.
*****************
I will send you a minimized example this evening (16/09).
 
Back
Top