xavier.batlle
Active member
- Local time
- Today, 16:47
- Joined
- Sep 1, 2023
- Messages
- 315
This Custom ListView System shows how to use the WINDOWS ListView control using some Windows APIs.
It’s intended to be an example not a full ready code to use on your applications, so use it at your own risk.
I know that similar behaviour can be achieved using continuous forms with conditional formating. This approach is not meant to be better or worse, it is simply another way of doing something.
CAVEATS
1. Core Control Replacement
It’s intended to be an example not a full ready code to use on your applications, so use it at your own risk.
I know that similar behaviour can be achieved using continuous forms with conditional formating. This approach is not meant to be better or worse, it is simply another way of doing something.
CAVEATS
- The first column is always left aligned, it can’t be changed
- In 32 bit MS Access, Access freezes after editing the code or opening the VBE, so if the code is edited you should exit MS Access and reenter if you want avoid it.
- This code uses Windows API subclassing so if it raises an error the application is likely to freeze.
- This application is difficult to debug because of the subclassing calls so when debugging is very likely to freeze.
- It is only fully compatible with MS Access 2016 onwards.
1. Core Control Replacement
- VBA ListBox Enhancement: It transforms a standard, limited Access ListBox to a Windows API ListView. The position, font name, font size and if it’s bold or not of the ListBox are used to set the ListView format. Columns width must be set manually using code (in twips).
- Dual-Architecture Support: Fully compatible with both 32-bit and 64-bit Microsoft Access
- DPI aware. The ListView size depends on the Windows scale.
- Row-Level Coloring: Supports specific background colors for individual rows (e.g., coloring a row red if it is "URGENT").
- Custom Selection Theme: Overrides the default Windows "blue" selection highlight to allow for custom selection background and text colors.
- Font Management: Allows for custom font names, sizes, and styles (bold/normal) via GDI font handles.
- Checkbox Support: Includes an optional checkbox column with a custom "Hand Cursor" that appears specifically when hovering over the checkbox area.
- Selection Modes: Supports both Single-Select (one row at a time) and Multi-Select (standard Windows multiple selection).
- Dynamic Data Loading: Easily populates data from DAO Recordsets or Arrays.
- State Management: Procedures to CheckAll, UncheckAll, or set a specific array of rows as "checked" by default.
- Report View: Organizes data into structured columns with defined headers.
- Alignment Control: Individual columns can be aligned Left, Right, or Center.
- Interaction Restrictions: Optionally enables or disables the user's ability to drag-and-drop to reorder columns.
- Columns can be resized using the mouse.
- Auto-Sizing: Logic to force-fit columns or specifically auto-size the last column to the control width.
- Full Unicode suport.
- Groups. Items can be assigned to a group and the group can be expanded and collapsed.
- Header Sorting: Automatically sorts data (alphabetically or numerically) when a user double-clicks a column header, with an ascending/descending toggle.
- Mass Deletion: Monitors the Delete key. When pressed, it can prompt the user and delete all selected rows simultaneously.
- Custom Events: Raises a specialized AfterDelete event that returns a Collection of the Unique IDs (ColumnRowSource) of the deleted items so you can sync the deletion with your underlying database.
- Data Extraction: Functions to retrieve checked or selected items as a Scripting Dictionary, mapping row indices to their underlying data values.
- 27/04/2026 Ver.22
Initial release.
- 29/04/2026 Ver.23
Added full Unicode support.
- 01/05/2026 Ver.24
The contents of the STATUS column become hidden for the selected records after being displayed. Fixed in ver.24
Selected items are now painted as unselected when a listbox losts its focus. Fixed in ver.24
Attachments
Last edited: