简体   繁体   English

水平滚动winforms listview

[英]Horizontal scroll winforms listview

Anyone know if its possible to enable horizontal scrolling ONLY in a windows forms listview (viewmode set to large icons). 任何人都知道是否可以在Windows窗体列表视图中启用水平滚动(viewmode设置为大图标)。 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. 我想要做的是制作一个listview,其高度足以只显示一行图标,我不想有多行。 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. 如果我使listview可滚动,那么它会自动生成多行并放入一个垂直滚动条,这是我不想要的。

Thanks in advance! 提前致谢!

Alignment属性设置为Left (如果在代码中执行,则设置为ListViewAlignment.Left )。

Just set one of the columns widths to: -2. 只需将其中一列宽度设置为:-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. 当将一个或多个列宽度设置为-2时,会出现滚动条,我不知道为什么会这样,但是我遇到了这个问题,因为我通过创建禁用宽度更改的事件来修复宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM