开发者

Making ListView scrollable in vertical direction

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 horiz开发者_运维知识库ontal scroll bar. I tried to find any properties to change scroll bar orientation. Is there any way to make it scrollable in vertical direction?


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


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


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


try setting this property

 View=Details

reference:

  • ListView.View Property


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜