Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #71
Online Version at http://www.codeoftheweek.com/membersonly/bi/0071.html (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.
Only one more week!! - Free Monthly Software Giveaway
This is the last week to enter! Be sure to enter at http://www.codeoftheweek.com/contest.html now! If you entered last month, please be sure to enter again because your entry from last month does not count towards the prize this month. The prize is development tools worth over $300.
In this Issue
We had planned on enhancing last week's issue about CD Audio, but we did not finish it in time. Instead we are introducing some API calls that enhance the way the ListView control works.
This source code is designed for VB 4.0 32-bit and up. Questions? Email us at questions@codeoftheweek.com.
basListView
The basListView module contain four subroutines that allow you to easily set or reset several new features Microsoft has added to the ListView control. This control is included in the Common Controls library (located in the COMCTL32.DLL). These routines require version 4.70 or greater of this control. It is usually included with Internet Explorer 3.x or 4.x. You can also download them separately at http://msdn.microsoft.com/developer/downloads/files/40Comupd.exe or get some additional information at http://www.codeoftheweek.com/updates/comctl.html
Subroutines
Public Sub lvFullRowSelect(lv As ListView, bFullRowSelectOn As Boolean)
Public Sub lvGridLines(lv As ListView, bGridLinesOn As Boolean)
Public Sub lvHeaderDragDrop(lv As ListView, bHeaderDragDrop As Boolean)
Public Sub lvTrackSelect(lv As ListView, bTrackSelect As Boolean)
Parameters
- lv - The ListView control that you want to modify.
- bFullRowSelectOn - When True it will force the ListView control to highlight an entire row instead of just the first column of a row.
- bGridLinesOn - When True it will draw in grid lines similiar to what you would see in a spreadsheet control.
- bHeaderDragDrop - When True it will allow you to click on the header and drag it to a different position. For example, you can click on the first column header and drag it to the last column. All the data below that column will continue to appear below the correct headings.
- bTrackSelect - When True it will track the mouse cursor and highlight the row that the cursor is hovering over. If you keep the cursor there for a few seconds it will automatically select that row as if you clicked the left mouse button. It will cause the Click event of the ListView control to fire.
Returns
Nothing.
Sample Usage
Assumes the ListView control you are using is called lvDrives.
lvFullRowSelect lvDrives, True
lvGridLines lvDrives, True
lvHeaderDragDrop lvDrives, True
lvTrackSelect lvDrives, True
Source Code
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0071.html
This document is available on the web
Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.
Other links
Contact Information
C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com