Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto resizing column widths in a CListCtrl

How can I make a CListCtrl to resize the width of its columns automatically? Usually, when an item in the list gets too long, the back end disappears from view and the user manually has to resize the width of the corresponding column. Is there any way to do this by code?

like image 660
Isuru Avatar asked Apr 09 '10 07:04

Isuru


2 Answers

Resizing the columns automatically is easy:

for(int i = 0;i < pListCtrl->GetHeaderCtrl()->GetItemCount();++i)
    pListCtrl->SetColumnWidth(i,LVSCW_AUTOSIZE_USEHEADER);

This will optimize the columns.

like image 53
dwo Avatar answered Sep 19 '22 15:09

dwo


Do you have the "No Scroll" option on? By default ("No Scroll" option off), if an item got too long a scroll bar would appear.

like image 41
djeidot Avatar answered Sep 20 '22 15:09

djeidot