Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
Aug 15, 2000

ListViewAdjustColumnWidth - Resize ListView's columns to account for their contents

Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long

Const LVM_SETCOLUMNWIDTH = &H1000 + 30
Const LVSCW_AUTOSIZE = -1
Const LVSCW_AUTOSIZE_USEHEADER = -2

' Adjust the width of a ListView control so that each item is fully visible
if second
' argument is True, column headers' width is also taken into account.
Sub ListViewAdjustColumnWidth(LV As ListView, Optional AccountForHeaders As
Boolean)
    Dim col As Integer, lParam As Long

    If AccountForHeaders Then
        lParam = LVSCW_AUTOSIZE_USEHEADER
    Else
        lParam = LVSCW_AUTOSIZE
    End If

    For col = 0 To LV.ColumnHeaders.Count - 1
        SendMessageLong LV.hwnd, LVM_SETCOLUMNWIDTH, col, lParam
    Next
End Sub
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date