Results 1 to 6 of 6

Thread: Changing The Color Of A List View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Changing The Color Of A List View

    How do I change the color of the columns in a list view control (detail view).


    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Changing The Color Of A List View

    You have two choices. The easy way is to set the UseItemStyleForSubItems property of each ListViewItem to False then set the BackColor of each ListViewSubItem in that column. The drawback is that if there is any space in the ListView the column will not be coloured. To do it properly you would have to draw the ListView yourself. There are ready-made controls or information on how to do it yourself at The Code Project or other places.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: Changing The Color Of A List View

    I can change each individual item that i add to the list but the main colum (the first one in the list at the very top) I cannot figure out how to change.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Changing The Color Of A List View

    Do you mean the first item in the list or the column header? If you mean the header then that would definitely require owner-drawing, perhaps even APIs to get to the underlying Win32 control. Have you read the stuff on The Code Project about owner-drawing ListViews?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: Changing The Color Of A List View

    this should get you started ... Customizing the header control in a ListView
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Changing The Color Of A List View

    Good old Code Project. I wish I'd thought of that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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