Listview columnwidth

R

Rikki

Hi

Is there a way to program a Listview control to
automatically adjust its columnwidths so it fits the
contents of the columns?

I have two columns in a listview, but havent found out how to do this yet.

thanks.
 
J

Jochen Kalmbach

Rikki said:
Is there a way to program a Listview control to
automatically adjust its columnwidths so it fits the
contents of the columns?

I have two columns in a listview, but havent found out how to do this
yet.

Set the width to "-1" and it will resize to fit the content...
If you set the last column to "-2" it will resize to the end...

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
 
G

Gary Milton

Hi Rikki,

To size the column width to the longest item in the column use...

columnHeader1.Width = -2;

...and to size the column width to the column header text use...

columnHeader1.Width = -1;

HTH,
Gary
 

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

Top