Automatickß velikost sloupc∙ v ListView

Postup:
Deklarujte v deklaraΦnφ Φßsti formulß°e:

Private Declare Function SendMessage Lib "user32.dll" _
   Alias "SendMessageA" (ByVal hWnd As Long, _
   ByVal Msg As Long, ByVal wParam As Long, _
   ByVal lParam As Long) As Long

Private Const LVM_FIRST = &H1000
Private Const LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30)
Private Const LVSCW_AUTOSIZE = -1
Private Const LVSCW_AUTOSIZE_USEHEADER = -2

Na formulß° p°idejte tlaΦφtko a ListView, kterΘmu nastavte View na Report. Pak:

Private Sub Form_Load()

   With ListView1
      .ColumnHeaders.Add , , "Header 1"
      .ColumnHeaders.Add , , "Header 2"
      .ColumnHeaders.Add , , "Header 3"
   End With

End Sub

Private Sub Command1_Click()

   Dim Column As Long
   Dim Counter As Long

   Counter = 0
   For Column = Counter To ListView1.ColumnHeaders.Count - 1
      SendMessage ListView1.hWnd, LVM_SETCOLUMNWIDTH, _
      Column, LVSCW_AUTOSIZE_USEHEADER
   Next

End Sub

Zp∞t

Autor: The Bozena