473,724 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cou nt;i++)
{
listView.Column s.Add(LVcolTitl es[i].ToString() ,
LVcolWidths[i], HorizontalAlign ment.Center);
} // columns load, data and color missing !!!
ListViewItem item1 = new ListViewItem("D ");
item1.SubItems. Add("TEST");
listView.Refres h();
item1.SubItems[0].BackColor=Syst em.Drawing.Colo r.Turquoise;
item1.SubItems[1].BackColor=Syst em.Drawing.Colo r.Tomato;
Console.WriteLi ne(item1.SubIte ms[0].Text + " " +
item1.SubItems[1].Text);
listView.Refres h();
}
Any ideas ? Thanks
Nov 15 '05 #1
3 2810

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: AcODnyXg7bcYXr9 oTHuBpiZJwtPWlA ==
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1873 97
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.Cou nt;i++)
| {
| listView.Column s.Add(LVcolTitl es[i].ToString() ,
| LVcolWidths[i], HorizontalAlign ment.Center);
| } // columns load, data and color missing !!!
| ListViewItem item1 = new ListViewItem("D ");
| item1.SubItems. Add("TEST");
| listView.Refres h();
| item1.SubItems[0].BackColor=Syst em.Drawing.Colo r.Turquoise;
| item1.SubItems[1].BackColor=Syst em.Drawing.Colo r.Tomato;
| Console.WriteLi ne(item1.SubIte ms[0].Text + " " +
| item1.SubItems[1].Text);
| listView.Refres h();
| }
|
|
| 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: AcODnyXg7bcYXr9 oTHuBpiZJwtPWlA ==
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1873 97| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.Cou nt;i++)
| {
| listView.Column s.Add(LVcolTitl es[i].ToString() ,
| LVcolWidths[i], HorizontalAlign ment.Center);
| } // columns load, data and color missing !!!
| ListViewItem item1 = new ListViewItem("D ");
| item1.SubItems. Add("TEST");
| listView.Refres h();
| item1.SubItems [0].BackColor=Syst em.Drawing.Colo r.Turquoise;| item1.SubItems[1].BackColor=Syst em.Drawing.Colo r.Tomato;
| Console.WriteLi ne(item1.SubIte ms[0].Text + " " +
| item1.SubItems[1].Text);
| listView.Refres h();
| }
|
|
| Any ideas ? Thanks

.

Nov 15 '05 #3

Hi Andrew,

You should set the UseItemStyleFor SubItems 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.publi c.dotnet.langua ges.csharp
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1875 72
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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: AcODnyXg7bcYXr9 oTHuBpiZJwtPWlA ==
| >| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| >| Path: cpmsftngxa06.ph x.gbl
| >| Xref: cpmsftngxa06.ph x.gbl
| microsoft.publi c.dotnet.langua ges.csharp:1873 97
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.Cou nt;i++)
| >| {
| >| listView.Column s.Add(LVcolTitl es[i].ToString() ,
| >| LVcolWidths[i], HorizontalAlign ment.Center);
| >| } // columns load, data and color missing !!!
| >| ListViewItem item1 = new ListViewItem("D ");
| >| item1.SubItems. Add("TEST");
| >| listView.Refres h();
| >| item1.SubItems
| [0].BackColor=Syst em.Drawing.Colo r.Turquoise;
| >| item1.SubItems[1].BackColor=Syst em.Drawing.Colo r.Tomato;
| >| Console.WriteLi ne(item1.SubIte ms[0].Text + " " +
| >| item1.SubItems[1].Text);
| >| listView.Refres h();
| >| }
| >|
| >|
| >| 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
13716
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 would like to try to write a script so that the background color in a cell in a table changes color (between two or three specified colors)). How do I get at the background color property in a table cell? Sorry for such a basic question.
1
8373
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 ! snippet can be dropped in intact private void ListViewBroke() { listView.View = View.Details; ArrayList LVcolTitles= new ArrayList(); LVcolTitles.Add("Drive");
0
1813
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 record. The ListView contains two columns; the first column contains a user-friendly field name and the second column contains the data content, with the first column being tied to an Item and the second column declared as a SubItem. This is all...
0
1166
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 ListView to display some icons. I also attached the icon to the Finish Button at the bottom of the dialog and there it is rendered as it should be! (The icon is in an ImageList) The Screenshot: http://kahuna-matata.piranho.com/escad.tiff
0
1135
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 and send it back to the database. Now the database have a new values. How do I updated the listview with the new info from database but still wanna keep the old age and old height (make color changes in new updated) without close the application.
1
1461
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 the cell depending on the value of the bound field. I need to use the following rules to set the content of the cell. I would appreciate anyone filling the code comments for needed code. Thanks a million. private void...
3
6735
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
8893
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 done by clicking the cell first then edit. Is this possible?
7
39534
!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 anywhere else are thwarted at just about every turn. So I developed a simple approach using WingDings. The WingDings font has a checked and unchecked box. In this project I place the unchecked box from WingDings centered in any cell I want a...
0
8868
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9388
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9160
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8062
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3209
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.