Results 1 to 4 of 4

Thread: VB6 - Listview Rows Backcolor (Without subclassing)

Threaded View

  1. #1

    Thread Starter
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    VB6 - Listview Rows Backcolor (Without subclassing)

    I have come across a piece of code that enables you to change the Backcolor property of any individual row, or rows, without the need for using subclassing. This is a big advantage for everybody, but especially those, like myself, with very limited knowledge of subclassing, but a better knowledge of the perils that it can bring.

    I have used this code and altered it a bit to make a fully commented example project to show how easy it is to use.

    It requires just the addition of a Picturebox control to your form and thats it, nothing more complicated than that.

    It uses the Line Method to fill in the colour in the specified places in the picturebox, i.e. the rows.
    See Here for information about the Line method (MSDN)

    You would then add a hidden column to the listview to store the value of the Checkbox, which would then be saved to, and loaded from your database when loading the other columns in your listview. Simple

    Limitations:
    I have noticed that when you get to more that approx 200 records, the colouring or the rows starts to go outside of the lines for each row.
    To try this, just change this line in the Form_Load event in the attached project:

    Code:
    '\\Load data into Listview
    For i = 0 To 200  <--Change to 1000
    The original author of this code is De ming Shang, who I give full credit to for such a simple, but effective alternative to subclassing.

    Screenshot of Listview with coloured rows.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by aikidokid; Feb 23rd, 2008 at 03:57 PM.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

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