简体   繁体   中英

Prevent listview items from showing in a second column

I am working with Winforms using C#.

It is easier to explain my question with a screen shot:

The list view on the left, notice how items15 and later are showing in a second column. I don't want that. I want it to have a vertical scroll bar and items15 to appear under item14, etc..not in a new column. I have set the "view" property on "List" too.

在此处输入图片说明

Thanks all.

You need to Set

listview.Scrollable = true;
listview.View = View.Details
listview.HeaderStyle = ColumnHeaderStyle.None;

Add a dummy column, its an important step, cause we changed the View to details :

    ColumnHeader header = new ColumnHeader();
    header.Text = "MyHeader";
    header.Name = "MyColumn1";
    listView.Columns.Add(header);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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