473,406 Members | 2,847 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,406 software developers and data experts.

cell properties in ListView - not updated in display

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()
{
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);
} // columns load, data and color missing !!!
ListViewItem item1 = new ListViewItem("D");
item1.SubItems.Add("TEST");
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);
listView.Refresh();
}
Any ideas ? Thanks
Nov 15 '05 #1
3 2780

Hi Andrew,

I think you missed the statement of adding the ListViewItem into the
ListView control.
You should add "listView.Items.Add(item1);" before the last refresh line.

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 properties in ListView - not updated in display
| Date: Thu, 25 Sep 2003 12:56:45 -0700
| Lines: 28
| Message-ID: <1e****************************@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: AcODnyXg7bcYXr9oTHuBpiZJwtPWlA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187397
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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()
| {
| 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);
| } // columns load, data and color missing !!!
| ListViewItem item1 = new ListViewItem("D");
| item1.SubItems.Add("TEST");
| 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);
| listView.Refresh();
| }
|
|
| Any ideas ? Thanks

Nov 15 '05 #2
Thanks - but it raises a new question ..

Why does only the first color show and why is it applied
across the row - instead of the cell item ??

Thanks Andrew
-----Original Message-----

Hi Andrew,

I think you missed the statement of adding the ListViewItem into theListView control.
You should add "listView.Items.Add(item1);" before the last refresh line.
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 properties in ListView - not updated in display| Date: Thu, 25 Sep 2003 12:56:45 -0700
| Lines: 28
| Message-ID: <1e****************************@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: AcODnyXg7bcYXr9oTHuBpiZJwtPWlA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187397| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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()
| {
| 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);
| } // columns load, data and color missing !!!
| ListViewItem item1 = new ListViewItem("D");
| item1.SubItems.Add("TEST");
| 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);
| listView.Refresh();
| }
|
|
| Any ideas ? Thanks

.

Nov 15 '05 #3

Hi Andrew,

You should set the UseItemStyleForSubItems property of ListViewItem to
false.
This will let the ListViewSubItem use its own style.

If there is still any question, please feel free to let me know. I am glad
to work with you.
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>
| References: <1e****************************@phx.gbl>
<AW**************@cpmsftngxa06.phx.gbl>
| Subject: RE: cell properties in ListView - not updated in display
| Date: Fri, 26 Sep 2003 09:47:29 -0700
| Lines: 82
| Message-ID: <14****************************@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: AcOETd+W/3XCc5j4S/SyrBTjyWRsTA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187572
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks - but it raises a new question ..
|
| Why does only the first color show and why is it applied
| across the row - instead of the cell item ??
|
| Thanks Andrew
| >-----Original Message-----
| >
| >Hi Andrew,
| >
| >I think you missed the statement of adding the
| ListViewItem into the
| >ListView control.
| >You should add "listView.Items.Add(item1);" before the
| last refresh line.
| >
| >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 properties in ListView - not updated in
| display
| >| Date: Thu, 25 Sep 2003 12:56:45 -0700
| >| Lines: 28
| >| Message-ID: <1e****************************@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: AcODnyXg7bcYXr9oTHuBpiZJwtPWlA==
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:187397
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| 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()
| >| {
| >| 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);
| >| } // columns load, data and color missing !!!
| >| ListViewItem item1 = new ListViewItem("D");
| >| item1.SubItems.Add("TEST");
| >| 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);
| >| listView.Refresh();
| >| }
| >|
| >|
| >| Any ideas ? Thanks
| >
| >
| >
| >.
| >
|

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim Madsen | last post by:
I am trying to learn JavaScript--(complete newbie--and don't know C or C++). I've been reading "The Book of JavaScript" by Thau. I don't see anything about table properties in the book. (I...
1
by: andrewcw | last post by:
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 !...
0
by: Steve | last post by:
I'm using a ListView control in conjunction with a TreeView control to display SqlServer database records. Clicking a Node in the TreeView refreshes the ListView with the content of the associated...
0
by: Alexander Wehrli | last post by:
Hello I've got a strange problem with System.Windows.Forms.ListView. It seems that this control is not able to render PNG-Icons properly. I've took a screenshot of a dialog in which i want the...
0
by: ttan | last post by:
Hi, I have Person information from a database and populated into 4 columns in my listview which is firstname, lastname, age, height. I do some changes in age and height by selecting single row...
1
by: js | last post by:
Question 1: I have the columns autogenerate = false and add each column programatically. One of the column is bound to a integer field (Due) of a recordset. I am trying to change the content of...
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
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...
7
!NoItAll
by: !NoItAll | last post by:
I needed to put checkboxes in several cells in a listview control. The way the listview control works you can really only have an "official" checkbox in the first cell, and attempts to put them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.