Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ListView Color

ListView Color

Scheduled Pinned Locked Moved C#
visual-studiographicsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dbetting
    wrote on last edited by
    #1

    Playing with the ListView to try to get colored backgrounds.

    ListViewItem lviGrossMargin = new ListViewItem(strListViewItem);
    lvOptions.Items.Add(lviGrossMargin);
    lviGrossMargin.SubItems[0].BackColor = System.Drawing.Color.Wheat;
    lviGrossMargin.SubItems[1].BackColor = System.Drawing.Color.SpringGreen;
    lviGrossMargin.SubItems[2].BackColor = System.Drawing.Color.YellowGreen;
    

    If I set lvOptions.Background, I color the entire background the identified color. But coding as above, I get the same result. Setting SubItems[0] to Wheat sets all SubItems. Setting SubItems[1] or [2] does nothing. Playing with the SubItems[n].Text does apply the expected text in each column. If I play with ForeColor, same as BackColor occurs. [0] is recognized and applies it to all SubItems. It is only the colors that don't seem to work. Is there a step I skipped that has to be done before manipulating colors or is it a feature that doesn't work correctly in VS Studio 2003?

    J 1 Reply Last reply
    0
    • D dbetting

      Playing with the ListView to try to get colored backgrounds.

      ListViewItem lviGrossMargin = new ListViewItem(strListViewItem);
      lvOptions.Items.Add(lviGrossMargin);
      lviGrossMargin.SubItems[0].BackColor = System.Drawing.Color.Wheat;
      lviGrossMargin.SubItems[1].BackColor = System.Drawing.Color.SpringGreen;
      lviGrossMargin.SubItems[2].BackColor = System.Drawing.Color.YellowGreen;
      

      If I set lvOptions.Background, I color the entire background the identified color. But coding as above, I get the same result. Setting SubItems[0] to Wheat sets all SubItems. Setting SubItems[1] or [2] does nothing. Playing with the SubItems[n].Text does apply the expected text in each column. If I play with ForeColor, same as BackColor occurs. [0] is recognized and applies it to all SubItems. It is only the colors that don't seem to work. Is there a step I skipped that has to be done before manipulating colors or is it a feature that doesn't work correctly in VS Studio 2003?

      J Offline
      J Offline
      Jared Parsons
      wrote on last edited by
      #2

      Have you tried setting the UseItemStyleForSubItems property of the ListViewItem to false? Jared Parsons jaredp@beanseed.org http://spaces.msn.com/members/jaredp/

      D 1 Reply Last reply
      0
      • J Jared Parsons

        Have you tried setting the UseItemStyleForSubItems property of the ListViewItem to false? Jared Parsons jaredp@beanseed.org http://spaces.msn.com/members/jaredp/

        D Offline
        D Offline
        dbetting
        wrote on last edited by
        #3

        That was the key. Thank you very much! :-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups