Results 1 to 4 of 4

Thread: ListView - ColumnHeader's width

  1. #1

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    ListView - ColumnHeader's width

    Did you see when you double-click over the "border" of the columnheader that its width changes to fit all the info in it? Is there any way to programmatically do this?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  2. #2
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342
    Once again, wish I could take credit.....but I cant...

    I found this, when I was attempting the same sort of thing....

    works great!

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lparam As Any) As Long

    Public Const LVM_FIRST = &H1000
    Public Const LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30)
    Public Const LVSCW_AUTOSIZE_USEHEADER As Long = -2
    ---------------------------------------------
    With ListView1
    colCnt = .ColumnHeaders.Count
    ReDim myCols(colCnt)
    intCol = 0
    For i = 1 To colCnt
    Call SendMessage(ListView1.hwnd, LVM_SETCOLUMNWIDTH, intCol, ByVal LVSCW_AUTOSIZE_USEHEADER)
    intCol = intCol + 1
    Next i
    End With
    --------------------------

    Put the with right after I populated the listview.....and it takes care of everything at one time.....

    Hope it helps!

  3. #3

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by VB4fun
    ...works great!....
    It does, indeed!! Thank you very much!!
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Addicted Member
    Join Date
    Aug 2006
    Posts
    211

    Re: ListView - ColumnHeader's width

    Perfect! Thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width