C#。我如何填写完整的ListView?所有项目和所有子项 [英] C#. How do I fill ListView fully? All Items and all Subitems

查看:382
本文介绍了C#。我如何填写完整的ListView?所有项目和所有子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家。如何填写完全的ListView一次。
例如,我点击了一些按钮,我LisView完全填满,所有的项目和我有所有子项。

everyone. How do I fill ListView fully at once. For example, I click some button and my LisView fills fully, all Items and all SubItems that I have.

推荐答案

我也被这个困惑时,我 System.Windows.Forms.ListView (我开始使用'米假设是的ListView 你指的是)。

I was also confused by this when I started using System.Windows.Forms.ListView (I'm assuming that is the ListView you're referring to).

从本质上讲,在ListView的每一行对应一个 ListViewItem的 .Items 收藏。该项目的文本出现在第一个的ListView中的列。当ListView控件在细节模式( .View = View.Details ),那么子项目集合使用,这是的属性的每个 ListViewItem的

Essentially, each row in the ListView corresponds to a single ListViewItem in the .Items collection. The text of the item appears in the first column of the ListView. When the ListView is in details mode (.View = View.Details), then the SubItems collection is used, which is a property of each ListViewItem.

该模式可以在例如$ C可以看出$ C为的ListView MSDN上

The pattern can be seen in the example code for ListView on MSDN:

ListViewItem item1 = new ListViewItem("item1",0);
item1.SubItems.Add("1");
item1.SubItems.Add("2");
item1.SubItems.Add("3");
ListViewItem item2 = new ListViewItem("item2",1);
item2.SubItems.Add("4");
item2.SubItems.Add("5");
item2.SubItems.Add("6");
listView1.Items.AddRange(new ListViewItem[]{item1,item2});

这篇关于C#。我如何填写完整的ListView?所有项目和所有子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆