cell properties in ListView - not updated in display

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrewcw

    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
  • Jeffrey Tan[MSFT]

    #2
    RE: cell properties in ListView - not updated in display


    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" <andrew.c.watts @boeing.com>
    | Sender: "andrewcw" <andrew.c.watts @boeing.com>
    | Subject: cell properties in ListView - not updated in display
    | Date: Thu, 25 Sep 2003 12:56:45 -0700
    | Lines: 28
    | Message-ID: <1e9f01c3839f$2 5e095e0$a001280 a@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



    Comment

    • andrewcw

      #3
      RE: cell properties in ListView - not updated in display

      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[color=blue]
      >-----Original Message-----
      >
      >Hi Andrew,
      >
      >I think you missed the statement of adding the[/color]
      ListViewItem into the[color=blue]
      >ListView control.
      >You should add "listView.Items .Add(item1);" before the[/color]
      last refresh line.[color=blue]
      >
      >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[/color]
      confers no rights.[color=blue]
      >
      >--------------------
      >| Content-Class: urn:content-classes:message
      >| From: "andrewcw" <andrew.c.watts @boeing.com>
      >| Sender: "andrewcw" <andrew.c.watts @boeing.com>
      >| Subject: cell properties in ListView - not updated in[/color]
      display[color=blue]
      >| Date: Thu, 25 Sep 2003 12:56:45 -0700
      >| Lines: 28
      >| Message-ID: <1e9f01c3839f$2 5e095e0$a001280 a@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[/color]
      microsoft.publi c.dotnet.langua ges.csharp:1873 97[color=blue]
      >| 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[/color]
      changes.[color=blue]
      >|
      >| 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[/color]
      [0].BackColor=Syst em.Drawing.Colo r.Turquoise;[color=blue]
      >| 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
      >
      >
      >
      >.
      >[/color]

      Comment

      • Jeffrey Tan[MSFT]

        #4
        RE: cell properties in ListView - not updated in display


        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" <andrew.c.watts @boeing.com>
        | Sender: "andrewcw" <andrew.c.watts @boeing.com>
        | References: <1e9f01c3839f$2 5e095e0$a001280 a@phx.gbl>
        <AWcL0X9gDHA.15 44@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: <141701c3844d$d f9618d0$a001280 a@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" <andrew.c.watts @boeing.com>
        | >| Sender: "andrewcw" <andrew.c.watts @boeing.com>
        | >| Subject: cell properties in ListView - not updated in
        | display
        | >| Date: Thu, 25 Sep 2003 12:56:45 -0700
        | >| Lines: 28
        | >| Message-ID: <1e9f01c3839f$2 5e095e0$a001280 a@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
        | >
        | >
        | >
        | >.
        | >
        |

        Comment

        Working...