ListView - autosizing columns to fit data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Does anyone have a bit of code that will auto-size the columns on a ListView
to fit the column headers AND data in those columns ?
Regards
Michael
 
<msdn
url="http://msdn.microsoft.com/library/d...emwindowsformscolumnheaderclasswidthtopic.asp">

.... The ColumnHeader can be set to adjust at run time to the column contents
or heading. To adjust the width of the longest item in the column, set the
Width property to -1. To autosize to the width of the column heading, set
the Width property to -2.

</msdn>

However, you have to do the above for every column by looping through the
column collection.

Hi,
Does anyone have a bit of code that will auto-size the columns on a ListView
to fit the column headers AND data in those columns ?
Regards
Michael
 
Back
Top