0

Hello I have have a listView on my Winform's panel as shown in the image:

Listview image

There you see some items are going out of bounds.

Here What I have tried to Fix it.

ListView1.AutoSize = true;

And according to this solution C# ListView Column Width Auto I tried to fix it by using

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

But it didn't work. I guess because its View to "list". I tried to resize its width by -2 but still same error.

It autosize is not possible on listview set to panel or because its view is set to "list". Horizontal Scrollbars also appreciated.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • Are you adding a column at runtime? If that's the case, in its constructor specify `Width = -2`. Something like `listView1.Columns.Add(new ColumnHeader() { Text = "[SomeText]", TextAlign = HorizontalAlignment.Left, Width = -2 });`. This also works if you change the View style to Details. ScrollBars are automatic if you have set `listView1.Scrollable = true;`. – Jimi Apr 27 '18 at 18:30
  • Alright will try this solution. Thank for your cooperation – Kaustubh Patange Apr 28 '18 at 04:20

1 Answers1

0

Try this:

ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);