Results 1 to 2 of 2

ListView Column Autofit

Threaded View

lubbamkt ListView Column Autofit 10-23-2016, 11:17 AM
Norie Re: ListView Column Autofit 10-23-2016, 11:22 AM
  1. #1
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    ListView Column Autofit

    Hi , I downloaded a sample file from the net which is a simple example of using ListView in excel. Next, I found a script about how to autofit the columns in the ListView. However, I dont know how to insert correctly the script so that the ListView Control could autofit all its columns. Could anyone help pls?
    Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
    
    Private Const LVM_FIRST = &H1000
    Public Sub LV_AutoSizeColumn(LV As ListView, Optional Column _
     As ColumnHeader = Nothing)
     
     Dim C As ColumnHeader
     If Column Is Nothing Then
      For Each C In LV.ColumnHeaders
       SendMessage LV.hWnd, LVM_FIRST + 30, C.Index - 1, -1
      Next
     Else
      SendMessage LV.hWnd, LVM_FIRST + 30, Column.Index - 1, -1
     End If
     LV.Refresh
    End Sub
    Attached Files Attached Files
    English is not my first language

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Can I determine the effect of autofit to .columnwidth prior to executing the autofit?
    By kadeo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-13-2016, 10:29 AM
  2. UserForm ListView - autofit rows?
    By mike.magill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2016, 09:57 AM
  3. Listview column background color
    By vini1508 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-29-2016, 12:15 AM
  4. [SOLVED] Listview add an index column at form initialization
    By BigDaddy01 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-28-2015, 11:29 AM
  5. Multi Column Listview
    By Jovillanueva in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2014, 09:34 AM
  6. Display data in ListView upon specific text in column Y
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2014, 05:51 PM
  7. Listview checked row delete line in Listview and in worksheet data
    By madforit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2012, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1