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.

2
  • 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, 2018 at 18:30
  • Alright will try this solution. Thank for your cooperation Apr 28, 2018 at 4:20

1 Answer 1

0

Try this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.