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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top