Bohn
Bohn

Reputation: 26919

Unnecessary ScrollBars showing in ListView

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);

Upvotes: 3

Views: 1424

Answers (1)

Hans Passant
Hans Passant

Reputation: 941397

header.Width = listView.Width;

Nope, you forgot about the border. Fix:

header.Width = listView.ClientSize.Width;

Upvotes: 5

Related Questions