Auto-resizing a listview column

B

Borges

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
 
C

Claes Bergefall

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

/claes
 

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