Results 1 to 3 of 3

Thread: [resolved] changing the forecolor of listview's subitem

  1. #1

    Thread Starter
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112

    [resolved] changing the forecolor of listview's subitem

    hello all,

    i got some code here that i should be expecting to display the red color on "Produce" category name in Northwind's categories... but the thing is, it displays red for the whole row... can anyone help... what did i miss? thanx in advance guys...
    Attached Files Attached Files
    Last edited by ayan; Feb 26th, 2004 at 09:21 PM.


    Keep fit with wossy
    "Finaly I can look as gay as I want..." - NoteMe

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You need to set the UseItemStyleForSubItems property of
    the parent ListViewItem to false before the
    individual subitem settings will have any effect, i.e.
    Code:
             private void LoadData(DataTable table, ListView list)
             {
                ListViewItem item;
                ListViewItem.ListViewSubItem subItem;
    
                list.Items.Clear();
                foreach(DataRow row in table.Rows)
                {
                   item = list.Items.Add(row[0].ToString());
                   item.UseItemStyleForSubItems = false;
    
                   for(int i = 1; i < table.Columns.Count; i++)
                   {
                      subItem = item.SubItems.Add(row[i].ToString());
                      
                      if( subItem.Text.Equals("Produce") == true )
                         subItem.ForeColor = Color.Red;
                   }
                }
             }

  3. #3

    Thread Starter
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    hello Aaron,

    Star you are... thanx very much...

    thanx... that's times ten to the power of forever...


    Keep fit with wossy
    "Finaly I can look as gay as I want..." - NoteMe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width