473,372 Members | 1,216 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 8351

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
1
by: redneon | last post by:
Is it possible to get the Handle property for a particular cell in a ListView? I'm wanting to turn a cell into a progress bar rather than just displaying text. If it's possible to get the Handle I...
1
by: nate axtell | last post by:
I need something that looks like a ListView but will allow SubItems of the ListView to be ComboBoxes, or allow the contents to be a ComboBox. So for each row in the ListView one of the columns...
3
by: Jerry Spence1 | last post by:
Does anyone have any code for floating a textbox or combo over a cell in ListView to simulate a cell edit function? Thanks -Jerry
6
by: Dave | last post by:
VB6 has a SorkKey property that you can setup on the ListView control to tell the ListView what column to use for sorting. In .NET there is a Sort() method and a SortOrder property that you can...
1
by: Lonewolf | last post by:
hi all, just want to find out if it is possible to set the gridline of individual cell in a listview using C#. Reason for this is I need to have a listview which has fixed number of columns and...
0
by: G.G. | last post by:
Hi to all, I have a vb.net form with a listview in "details" mode. I want to click each cell of each listview item so I can show a window that modifies some properties of the cell object. I've...
12
by: keirnus | last post by:
Hello, I am back and got a new question. I have various data to be displayed in a table. I think a listview will do. I want to edit the value of a certain cell (column,row). The process is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.