Tearsdontfalls
Tearsdontfalls

Reputation: 777

Resize Listviewcolumns(Details

I created so many listviews in my project, that im too lazy to add to each listview a resize event with percentages. Is there any other trick, who just scales the columns so as they are?

thx

Upvotes: 0

Views: 286

Answers (3)

David Pokluda
David Pokluda

Reputation: 10971

This question is hard to answer because there is not enough details. If you have a list view and it is populated then you can use the following code to auto resize columns:

this.listControl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

It works fine in my projects so you might give it a try as well.

Upvotes: 0

Adam Bruss
Adam Bruss

Reputation: 1674

There is an easy way to autosize them. I can't remember exactly but it involves setting the column width to 0, -1 or -2. It's probably -1 or -2. Try that out.

Upvotes: 1

Uranus
Uranus

Reputation: 1690

If you handle the Resize event using the same code for each ListView, it is sufficient to create a single method and use it as event handler for each ListView. At the time the event handler code is executed, you can obtain an instane which raised the event from the sender parameter. Besides the parameter is of the Object type, it actually contains a reference to a ListView instance. So, you can cast the parameter value to the ListView type.

Upvotes: 1

Related Questions