Reputation: 3343
I am using a System.Windows.Forms.ListView
with checkboxes = true
.
I can see that when the list items are more than what can fit, I get a horizontal scroll bar. I tried to find any properties to change scroll bar orientation.
Is there any way to make it scrollable in vertical direction?
Upvotes: 41
Views: 93032
Reputation: 231
I think the only way to force the ListView scroll vertically and view items as "Title" mode, is this :
ListView.View = View.Details;
ListView.HeaderStyle = ColumnHeaderStyle.None;
and add JUST ONE Column
Upvotes: 23
Reputation: 895
You'll need
listView1.View = System.Windows.Forms.View.SmallIcon;
Then your control will have vertical scrollbar and behaviour pretty much the same like View.List
Upvotes: -1
Reputation: 5569
You need to Set
Listview1.Scrollable = true;
Listview1.View = View.Details
This will only work correctly if you have added some columns in your Listview1, So add a dummy column. like,
ColumnHeader header = new ColumnHeader();
header.Text = "";
header.Name = "col1";
listView1.Columns.Add(header);
Upvotes: 64
Reputation: 42125
You can't change the scroll bar orientation, per sé.
You get a vertical scrollbar if you have items that go off the bottom of the listview, and a horizontal scrollbar if you have items that go off the right-hand side of the listview.
So if you want to control the scrollbars, you actually do this by controlling the content. Personally I only ever use ListViews in Detail mode, but to take that as an example, you would make sure that your column headers are sized such that they all fit in the horizontal space.
Upvotes: 0
Reputation: 15016
The ListView should also display a vertical scrollbar automatically if you've got enough items in the collection (i.e. more than can be displayed on the ListView currently).
Upvotes: 0