470,821 Members | 1,995 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,821 developers. It's quick & easy.

cell in ListView - bkgrd color not working

How is it ( or can I ) make each subitem reflect the
background color ? In my case the first color is applied
across the row - even though I can read the values back
out correctly ? Thanks ! snippet can be dropped in intact

private void ListViewBroke()
{
listView.View = View.Details;
ArrayList LVcolTitles= new ArrayList();
LVcolTitles.Add("Drive");
LVcolTitles.Add("Cust");
int [] LVcolWidths = {50,50};
for(int i = 0;i< LVcolTitles.Count;i++)
{
listView.Columns.Add(LVcolTitles[i].ToString() ,
LVcolWidths[i],
HorizontalAlignment.Center);
}
ListViewItem item1 = new ListViewItem("D");
item1.SubItems.Add("TEST");
listView.Items.AddRange(
new ListViewItem[] {item1}
);
listView.Refresh();
item1.SubItems[0].BackColor=System.Drawing.Color.Turquoise;
item1.SubItems[1].BackColor=System.Drawing.Color.Tomato;
Console.WriteLine(item1.SubItems[0].Text + " " +
item1.SubItems[1].Text + item1.SubItems[1].BackColor);
listView.Refresh();
}
Nov 15 '05 #1
1 8217

Hi Andrew,

Sorry for letting you wait so long.
These 2 days are weekand, so I did not reply to you.
Thank you for your understanding.

I have replied in another post of you.
You should set the UseItemStyleForSubItems property of ListViewItem to
false,
letting the ListViewSubItem use its own style.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "andrewcw" <an************@boeing.com>
| Sender: "andrewcw" <an************@boeing.com>
| Subject: cell in ListView - bkgrd color not working
| Date: Fri, 26 Sep 2003 09:52:44 -0700
| Lines: 30
| Message-ID: <03****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOETpt656dwh/HdThasXRNzzKbn6w==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187573
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| How is it ( or can I ) make each subitem reflect the
| background color ? In my case the first color is applied
| across the row - even though I can read the values back
| out correctly ? Thanks ! snippet can be dropped in intact
|
| private void ListViewBroke()
| {
| listView.View = View.Details;
| ArrayList LVcolTitles= new ArrayList();
| LVcolTitles.Add("Drive");
| LVcolTitles.Add("Cust");
| int [] LVcolWidths = {50,50};
| for(int i = 0;i< LVcolTitles.Count;i++)
| {
| listView.Columns.Add(LVcolTitles[i].ToString() ,
| LVcolWidths[i],
| HorizontalAlignment.Center);
| }
| ListViewItem item1 = new ListViewItem("D");
| item1.SubItems.Add("TEST");
| listView.Items.AddRange(
| new ListViewItem[] {item1}
| );
| listView.Refresh();
| item1.SubItems[0].BackColor=System.Drawing.Color.Turquoise;
| item1.SubItems[1].BackColor=System.Drawing.Color.Tomato;
| Console.WriteLine(item1.SubItems[0].Text + " " +
| item1.SubItems[1].Text + item1.SubItems[1].BackColor);
| listView.Refresh();
| }
|

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by J_Max | last post: by
1 post views Thread by redneon | last post: by
1 post views Thread by nate axtell | last post: by
3 posts views Thread by Jerry Spence1 | last post: by
6 posts views Thread by Dave | last post: by
1 post views Thread by Lonewolf | last post: by
reply views Thread by G.G. | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.