I have this list view in csharp and would like the columns to fill the entire space but I cannot find that property. In the DataGridView there is a property called AutoSizeColumnMode is there such a property in the listView
Asked
Active
Viewed 1,633 times
2
-
http://stackoverflow.com/questions/1257500/c-sharp-listview-column-width-auto – User6667769 Apr 10 '17 at 12:30
-
Possible duplicate of [C# ListView Column Width Auto](http://stackoverflow.com/questions/1257500/c-sharp-listview-column-width-auto) – François Maturel Apr 10 '17 at 12:42
2 Answers
4
You can do this,
YourListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
YourListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
EDIT
Since you wanted the columns to be equally sized, as @berkay mentioned, you could do this,
foreach (ColumnHeader column in YourListView.Columns){
column.Width = YourListView.Width / YourListView.Columns.Count;
}
The above code will read each column height and and divide the total width by the number of columns.

Sajeetharan
- 216,225
- 63
- 350
- 396
-
Many thanks Sajeetharan. But it does not fill the entire space. two columns to be split equally among the listView – Elias Apr 10 '17 at 12:28
-
you might have to write some code for that, check this https://nickstips.wordpress.com/2010/11/10/c-listview-dynamically-sizing-columns-to-fill-whole-control/ – Sajeetharan Apr 10 '17 at 12:32
3
Try this,
foreach (ColumnHeader column in listView1.Columns){
column.Width = listView1.Width / listView1.Columns.Count;
}
Hope helps,

Berkay Yaylacı
- 4,383
- 2
- 20
- 37