Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unnecessary ScrollBars showing in ListView

Tags:

c#

winforms

C# WinForms: Can't figure out why it is showing scoll bars in this screen shot? I still want it to show Vertical scroll bars "as needed", but this horizontal scroll bar? Why is it showing? My items aren't that wide...

enter image description here

here is also some initialization I am doing on FormLoad ..if any part of that is the culprit

    listView.Scrollable = true;
    listView.FullRowSelect = true;
    listView.View = View.Details;
    listView.HeaderStyle = ColumnHeaderStyle.None;
    ColumnHeader header = new ColumnHeader();
    header.Text = "MyHeader";
    header.Name = "MyColumn1";
    header.Width = listView.Width;
    listView.Columns.Add(header);
like image 594
Bohn Avatar asked Dec 20 '25 06:12

Bohn


1 Answers

header.Width = listView.Width;

Nope, you forgot about the border. Fix:

header.Width = listView.ClientSize.Width;
like image 141
Hans Passant Avatar answered Dec 21 '25 20:12

Hans Passant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!