469,578 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Auto-resizing a listview column

Hi folks,

I've got a listview with several columns, and I'm trying to
automatically resize the columns when the control gets painted. I know
there are methods for this in .NET 2 but we're not using it yet, so
I've gotta get it working the old-fashioned way.

There's built-in functionality for this already. If the user
double-clicks on a coumn divider the listview control auto resizes the
column nicely. I'm just trying to do the same thing programmatically.
Is there some way for me to raise a divider double click event in c#?
I can't seem to find it. Or maybe I can call the event handler that's
built into the listview and resize that way.

Any ideas?

Thanks,

B

Sep 14 '06 #1
1 3198
Just set the Width property to -1 (or -2 depending on your needs)
See the Remarks section in the docs for ColumnHeader.Width

/claes

"Borges" <cs********@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Hi folks,

I've got a listview with several columns, and I'm trying to
automatically resize the columns when the control gets painted. I know
there are methods for this in .NET 2 but we're not using it yet, so
I've gotta get it working the old-fashioned way.

There's built-in functionality for this already. If the user
double-clicks on a coumn divider the listview control auto resizes the
column nicely. I'm just trying to do the same thing programmatically.
Is there some way for me to raise a divider double click event in c#?
I can't seem to find it. Or maybe I can call the event handler that's
built into the listview and resize that way.

Any ideas?

Thanks,

B

Sep 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Manlio Perillo | last post: by
1 post views Thread by Lew | last post: by
5 posts views Thread by Robert Downes | last post: by
20 posts views Thread by Vijay Kumar R. Zanvar | last post: by
5 posts views Thread by maya | last post: by
22 posts views Thread by nospam_news | last post: by
2 posts views Thread by Piotr K | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.