'Declaraciones 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_SETCOLUMNWIDTH = &H1000 + 30 Private Const LVSCW_AUTOSIZE = -1 Private Const LVSCW_AUTOSIZE_USEHEADER = -2
'Funcion que cambia de tamano las columnas de un listview. Public Sub AdjustColumnWidth(LV As ListView, AccountForHeaders As Boolean, Optional AjusttoLast As Boolean = True) On Error Resume Next Dim Col As Integer Dim lParam As Long If AccountForHeaders Then lParam = LVSCW_AUTOSIZE_USEHEADER Else lParam = LVSCW_AUTOSIZE End If For Col = 0 To LV.ColumnHeaders.Count - 1 If AjusttoLast Then SendMessage LV.hwnd, LVM_SETCOLUMNWIDTH, Col, ByVal lParam Else If Not Col = LV.ColumnHeaders.Count - 1 Then SendMessage LV.hwnd, LVM_SETCOLUMNWIDTH, Col, ByVal lParam End If Next End Sub
Invocamos a la funcion despues de cargar nuestro listview
.
AdjustColumnWidth ListView1, True
0 comentarios:
Publicar un comentario