Horizontal scroll winforms listview

自闭症网瘾萝莉.ら 提交于 2020-01-20 04:11:29

问题


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.



来源:https://stackoverflow.com/questions/1044599/horizontal-scroll-winforms-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!