34

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?

Jeankowkow
  • 752
  • 10
  • 28
Ravisha
  • 2,983
  • 8
  • 36
  • 61

6 Answers6

57

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);
shytikov
  • 8,154
  • 7
  • 50
  • 90
NileshChauhan
  • 5,233
  • 2
  • 27
  • 43
  • 10
    From a proposed edit (not me): set HeaderStyle to None to hide it ! Now you have a ListView like a Title-View one – Marc Gravell Mar 01 '11 at 11:38
  • 8
    u should add Listview1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize) for proper look – eddy white Jan 19 '15 at 15:17
  • Thanks! This answer and the 2 comments above saved me several hours of trial and error to get a ListView to look like a simple vertically scrollable ListBox. – Fabien Teulieres Mar 19 '21 at 01:38
19

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

radbyx
  • 8,605
  • 18
  • 75
  • 119
Sepehr Shojaee
  • 191
  • 1
  • 2
1

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.

Neil Barnwell
  • 38,622
  • 28
  • 141
  • 213
0

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

Dave
  • 13,797
  • 12
  • 80
  • 140
0

try setting this property

 View=Details

reference:

Asad
  • 19,788
  • 16
  • 65
  • 91
  • I have tried with all combination of this.Its not helping.Besides this is to configure the view of list items not the scroll bar orientation:( – Ravisha Feb 22 '10 at 05:48
0

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

Danil
  • 511
  • 5
  • 5