Hello Simanovsky,
> Could anybody advice how to calculate the width of the
> widest item in the ListView?
>
> I need to resize a ListView according to the size of the
> strings stored in it, particulary to avoid horizontal
> scrolling. To calculate the new dimensions of the control
This feature is built in to the .net ListView. After you've added
rows to the ListView, execute this code:
<Untested code>
foreach( ColumnHeader c in lvwMyListView.Columns )
c.Width = -2;
</Untested code>
Setting the width to -2 will resize a column to accomodate the
longest string in that column (in Details view).
Hope this helps,
Len
|