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. Different Colored Items in ListView

Different Colored Items in ListView

Scheduled Pinned Locked Moved C#
question
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.
  • R Offline
    R Offline
    rahultaing
    wrote on last edited by
    #1

    can anyone tell me some way to set different colors for different Items that I add to my listview? I am inserting strings into a listview, but I want them to appear in different colors, how can I do that?

    R 2 Replies Last reply
    0
    • R rahultaing

      can anyone tell me some way to set different colors for different Items that I add to my listview? I am inserting strings into a listview, but I want them to appear in different colors, how can I do that?

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You can set the foreground and background colors of items in a list view, as in:

      ListViewItem lvi = myListView.Items.Add ("Hello");
      lvi.ForeColor = Color.Red;
      lvi.BackColor = Color.Beige;

      /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • R rahultaing

        can anyone tell me some way to set different colors for different Items that I add to my listview? I am inserting strings into a listview, but I want them to appear in different colors, how can I do that?

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        In reply to your email:

        Do you know how do I do this:

        I am adding items to a listView, but during runtime I see them being
        displayed one next to the other, instead of one below the other.
        I mean that I see that item 2 gets added to the listView and is
        displayed parallel to item 1 present in the listView instead of being
        displayed below item 1. Can you tell me the reason and possible
        solution to display it one below the other?

        Best Regards
        Rahul Taing

        Set the list view's View property to Details. /ravi PS: Am posting your email here so others may benefit from your question. Replying to a post (vs. sending email) is the preferred way of communicating at CP as it allows others to share (and provide) information. My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        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