C# 在列表视图中的分隔行中添加项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/819402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:26:13  来源:igfitidea点击:

Add item in separated rows in listview

c#winformslistview

提问by Sadegh

When i add a listview to my form and in form load event i write below code , items added in the same row not in separated rows , how can i add them to separated rows

当我将列表视图添加到我的表单并在表单加载事件中我写在下面的代码中时,添加在同一行中而不是在分隔行中的项目,我如何将它们添加到分隔行中

            listView1.MultiSelect = true;
            listView1.CheckBoxes = true;
            listView1.Items.Add("Item 1");
            listView1.Items.Add("Item 22");
            listView1.Items.Add("Item 333");

采纳答案by Frederik Gheysels

try this out

试试这个

listView1.View = View.List;

回答by Matt Hamilton

Taking a stab at this, I'd suggest that it's because your ListView is defaulting to small icons or tiles. Try adding this line anywhere there:

试一试,我建议这是因为您的 ListView 默认为小图标或图块。尝试在任何地方添加此行:

listView1.View = View.Details;

回答by Frederik Gheysels

Are you sure ?
Normally, with this code, you should have added 3 items, and you should see 3 rows when the View property of the ListView is set to Details

你确定吗 ?
通常,使用此代码,您应该添加了 3 个项目,并且当 ListView 的 View 属性设置为时,您应该看到 3 行Details