Auto-resizing a listview column

  • Thread starter Thread starter Borges
  • Start date Start date
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
 
Just set the Width property to -1 (or -2 depending on your needs)
See the Remarks section in the docs for ColumnHeader.Width

/claes
 
Back
Top