VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Custom Drawn ListView

by Citizen_Suicide (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)


This Will allow the programmer to customise the individual foreground background colours of the different listview items, and can give a listview a custom highlight colour, with out modification to this code.
Any votes and/or comments will be much appreciated.

Inputs
Add this code in the Form_Load event: Attach Me.hWnd, ListView And don't forget to UnAttach in your form_unload event: UnAttach me.hWnd To set whether a custom highlight colour is used call: UseCustomHighLight True or UseCustomHighLight false To Set whether a listviews items will have alternating colours call: UseAlternatingColour True or UseAlternatingColour False To set the custom highlight colour use this code: Dim NewColours as ItemColourType NewColours.ForeGround = Your Colour Code Here NewColours.BackGround = Your Colour Code Here SetHighLightColour NewColours To Set the custom alternating colour (the first colour is the default foreground/background colours) call: Dim NewColours as ItemColourType NewColours.ForeGround = Your Colour Code Here NewColours.BackGround = Your Colour Code Here SetCustomColour NewColours
Assumes
Nothing really, may help to read the readme.txt file and understand the concepts before trying to customise this code.
Code Returns
A Custom Drawn ListView control
Side Effects
With multi selection on and more than one item highlighted there is an intrusive refresh flicker, caused by continual refresh. You'll have to be careful when running in the IDE, as subclassing can crash your computer. Obviously this is slower than letting the listview look after itself. There can be problems getting the colours to display right during scrolling, they can appear missaligned - i know not why. Highlight colour tends to dissapear on coloumns that are being resized, and will not reappear until the item is clicked, even though the item is still flagged as selected. Again i'm not sure what causes this. The selection is always hidden when the listView doesn't have the focus, no matter what value is set in hideselection. Any other listviews on the same form will not display correctly. Setting alternating colours will overlay any background picture.
API Declarations
Many - see code ModAPIDeclares

Rate Custom Drawn ListView

Download Custom Drawn ListView

Download Custom Drawn ListView (62 KB)

Custom Drawn ListView Comments

No comments have been posted about Custom Drawn ListView. Why not be the first to post a comment about Custom Drawn ListView.

Post your comment

Subject:
Message:
0/1000 characters