|
Determine the number of visible items in a ListView control
|
Total Hit (4504) |
Microsoft "forgot" to provide the ListView control with the GetVisibleCount property, as it did, for example, with the TreeView control. However, getting this information is as easy as sending a message to the control:
«Code LangId=1»
Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNT
....Read More |
Rating
|
|
|
Determine the optimal width for ListView columns
|
Total Hit (3066) |
Here's a simple but effective trick to ensure that the column of a ListView control is wide enough to display the entire string you're assigning to the column title or to an element. Just drop a Label on the form, set its Autosize property to True and Visible property to False. Also, ensure that the
....Read More |
Rating
|
|
|
Get full control on the text typed in a ListView's item
|
Total Hit (3519) |
The ListView control exposes the AfterLabelEdit event to let the programmer validate the text entered in a ListItem, but there is no way to trap keys as they are typed by the user. This prevents you from discarding unwanted characters while the user types them.
You can work around this problem by
....Read More |
Rating
|
|
|
Limit the length of an item in a ListView control
|
Total Hit (3817) |
The ListView control doesn't expose any property that lets you limit the amount of text users can type when editing an item's label. However, you can do the trick with a couple of SendMessage API calls from within the BeforeLabelEdit event: with the LVM_GETEDITCONTROL message you retrieve the handle
....Read More |
Rating
|
|
|
Prevent dragging elements in a ListView control
|
Total Hit (3201) |
The ListView control doesn't expose any property that lets you disable the dragging of its elements. To do so, you must trap the WM_NOTIFY message that the ListView control sends its parent form when the drag operation begins, and "eat" it. Using the MSGHOOK.DLL subclassing library it's easy to acco
....Read More |
Rating
|
|
|
Selecting an entire row in a ListView
|
Total Hit (3751) |
The ListView control that comes with VB6 lets you select an entire row by setting its FullRowSelect property to True. If you are working with VB5 or you're using VB6 with the old version of the Microsoft Windows Controls this capability isn't avaible, but if you have installed the comctl32.dll versi
....Read More |
Rating
|
|
|
|
|
|
|
|
|
How to get a listview control to sort numbers correctly...
|
Total Hit (2448) |
This is one I discovered after banging my head against the wall for a few hours trying to get a list view control to sort numbers correctly. When trying to create a list view control in report mode that would allow a user to quickly sort by a text listing (in this case a column of state abbreviation
....Read More |
Rating
|
|
|
|
Presenting a Non-Selectable 'No Data' Picture in a ListBox
|
Total Hit (1716) |
The VBnet page Customizing the ListView's Appearance via API showed how to use SendMessage with the LVBKIMAGE structure to display images in the data window of a listview control. Although Windows' normal list box does not support such functionality, we can still fake this functionality using the B
....Read More |
Rating
|
|
|
Sorting ListView ListItems Using Callbacks
|
Total Hit (1537) |
Sorting numeric values with the ListView control's built-in sort mechanism has always left much to be desired. Because the ListView stores the item and SubItem data as strings, the default sorting algorithm sorted numbers in string format. This meant that instead of a sort of 1, 2, 3, 20, 35, the Li
....Read More |
Rating
|
|
|
Substituting a ListView for a Combo's Dropdown List
|
Total Hit (1138) |
Once the methods to trap the display of a combo's default dropdown list had been coded, substituting another control in place of the dropdown list is as easy as modifying the basic routine to point to the new control. Based on the code listed above, the only changes needed to support a listview cont
....Read More |
Rating
|
|
|
|
Definitions of the ListView API Members
|
Total Hit (1096) |
This method is intended for Visual Basic 5 or Visual Basic 6 where the Common Control library used is the MSComCtl 5 version (comctl32.ocx). Because the VB6-specific mscomctl.ocx (Common Controls 6) is a complete implementation of comctl32.dll and not reliant on the version of comctl32.dll installed
....Read More |
Rating
|
|
|
ListView Demo 1 - Obtaining the File Path
|
Total Hit (1075) |
This page details the code required to construct the base form, and the code necessary to retrieve the user's selection using the Windows Browse dialog.
When the demo is completed, the final app will retrieve the users selection and populate the listview with selected files from that folder, comp
....Read More |
Rating
|
|
|
ListView Demo 2 - Populating the ListView
|
Total Hit (1710) |
This page details the code required to populate the listview control with files matching the selected file spec using the APIs FindFirstFile, FindNextFile and the WIN32_FIND_DATA type.
When the demo is completed, the final app will retrieve the users selection and populate the listview with selec
....Read More |
Rating
|
|
|
ListView Demo 3 - Adding Sorting Functionality
|
Total Hit (1072) |
This page adds a popup menu and the routines necessary to sort and change list views.
When the demo is completed, the final app will retrieve the users selection and populate the listview with selected files from that folder, complete with associated icons, file name, file type, file size and cre
....Read More |
Rating
|
|
|
ListView Demo 4 - Adding the Associated Icons
|
Total Hit (1231) |
By far the most complicated code yet, this page adds the code necessary to retrieve the Windows associated icon for a given file, assign it to an imagelist dynamically, and use it to display with the file in the listview. Among the features of the method detailed here is the reuse of an icon if it h
....Read More |
Rating
|
|
|
Autosizing ListView Columns via API
|
Total Hit (1823) |
The ListView control in both VB5 and VB6 implementations supports SendMessage with the LVSCW_AUTOSIZE and LVSCW_AUTOSIZE_USEHEADER messages to cause the ListView to adjust its column widths to maximize data display. This page shows how to use these messages to resize the columns to fit the longest c
....Read More |
Rating
|
|
|
Creating a Ledger-Style Listview Report Background
|
Total Hit (1196) |
This page takes a different approach based on the Picture property of the VB5 and VB6 listviews. With this demo, picture box properties are set to match the size and font of the listview. The demo then draws two filled rectangles inside the picture box corresponding to ledger colours specified, and,
....Read More |
Rating
|
|
|
Customizing the ListView's Appearance via API
|
Total Hit (1681) |
Once again, the SendMessage API, in conjunction with the new extended style flags for the ListView control, provides a means to customize the appearance of the listview common control in a Visual Basic application.
By combining the new LVBKIMAGE structure (Type), and specifying the LVBKIF_SOURCE_U
....Read More |
Rating
|
|
|
Detecting ListView SubItem Clicks in Normal And FullRowSelect Mode
|
Total Hit (1148) |
This page demonstrates using the LVHITTESTINFO type along with the LVM_SUBITEMHITTEST message to determine where on the control the mouse was clicked, regardless of the view mode or whether the FullRowSelect feature has been enabled (Label1). The code is provided in the MouseDown event to both take
....Read More |
Rating
|
|
|
Determining a ListView's Visible Item Count
|
Total Hit (1743) |
This shows a quick call you can add to any ListView code to determine the number of currently-visible ListItems in the control when in Report mode. By calling SendMessage with the LVM_GETCOUNTPERPAGE message, the call returns the number of items that can be completely contained in the visible area o
....Read More |
Rating
|
|
|
Highlighting a Listview Report Column
|
Total Hit (1599) |
Just as the picture property was used in Creating a Ledger-Style Listview Report Background to simulate a ledger-style background for the listview, this code provides a means to highlight the data in a specific column in the control using the same technique.
To do this, the the default background c
....Read More |
Rating
|
|
|