Sign in to follow this  
Followers 0
nullschritt

Autosizing a listview after it has been edited?

3 posts in this topic

Hello all I have been using the following function to resize my listview to show all text.

func _sizeconvolist()
   GUICtrlSendMsg($convolist, $LVM_SETCOLUMNWIDTH, 0, -1) ; $LVSCW_AUTOSIZE
    GUICtrlSendMsg($convolist, $LVM_SETCOLUMNWIDTH, 0, -2) ; $LVSCW_AUTOSIZE_USEHEADER
EndFunc

It works great until I do 

_GUICtrlListView_BeginUpdate($convolist)
_GUICtrlListView_DeleteAllItems($convolist)
_GUICtrlListView_InsertItem($convolist, "Some Text")
_sizeconvolist()
_GUICtrlListView_EndUpdate($convolist)
_sizeconvolist()

After this point, the listview no longer auto resizes, anyone have any idea why?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi nullschritt

why you use _sizeconvolist() before AND after  _GUICtrlListView_EndUpdate($convolist) and not only after?

anyway, have You tried with _GUICtrlListView_SetColumnWidth($hWnd, $iCol, $iWidth) as BrewManNH suggested you in this >post?

EDIT:

from the autoit help for _GUICtrlListView_SetColumnWidth:

using $LVSCW_AUTOSIZE as value for $iWidth, Automatically sizes the column.

bye

Edited by Pincopanco

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Hi,

I would doing something like this:

_GUICtrlListView_SetColumnWidth($convolist, 0, $LVSCW_AUTOSIZE)
If _GUICtrlListView_GetColumnWidth($convolist, 0) < $default_listview_width Then
        _GUICtrlListView_SetColumnWidth($convolist, 0, $default_listview_width)
EndIf

 

$default_listview_width is your const, it's the default width when create the ListView

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0