Horizontal scroll winforms listview

2019-01-24 14:18发布

问题:

Anyone know if its possible to enable horizontal scrolling ONLY in a windows forms listview (viewmode set to large icons). What I want to do is make a listview whose height is sufficient to only show one row of icons, and I don't want to have multiple rows. Just one very long row that a user would have to scroll horizontally to get to out-of-range icons. If I make the listview scrollable then it automatically makes multiple rows and puts in a vertical scrollbar, which I don't want.

Thanks in advance!

回答1:

Set the Alignment property to Left (or ListViewAlignment.Left if you do it in code).



回答2:

Just set one of the columns widths to: -2. the scroll bar will appear:

public Form1()
    {Listview1.Columns.Add("Name", 100, HorizontalAlignment.Center);
     Listview1.Columns.Add("Item Name", -2, HorizontalAlignment.Center);
     Listview1.Columns.Add("Item Link", 300, HorizontalAlignment.Center);
     }

When setting one or more of the columns width to -2, the scroll bar appears, I don't know why actually, but I had this problem because I fixed the width by creating an event that disables width change.