C#中ListView项的子项 [英] Sub item of ListView item in c#

查看:117
本文介绍了C#中ListView项的子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过xaml文件创建了一个列表视图,并向其中添加了项目.如何在该列表视图中添加子项?我没有获得subitems属性.请帮助我

这是我用于创建Listview的代码.

Hi I have created a listview through xaml file and have added items to it. How to add subitems to that list view? I am not getting subitems property. Pls help me

This is my code for Listview creation.

<ListView Height="228" HorizontalAlignment="Left" Margin="284,79,0,0" Name="lsvAnalysts" VerticalAlignment="Top" Width="381" SelectionChanged="lsvAnalysts_SelectionChanged"/>




这是我向其中添加项目的代码






This is my code for adding items to it



lsvAnalysts.Items.Add("1");
lsvAnalysts.Items.Add("2");

推荐答案

您要阅读的MSDN链接为 http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.aspx [^ ]和 http://msdn.microsoft.com/en -us/library/system.windows.forms.listviewitem.listviewsubitem.aspx [
The MSDN links you''ll want to read are http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.aspx[^]and http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.listviewsubitem.aspx[^].
You access the subitems of your list view item through the ListViewItem.SubItems property Most important thing to remember is that the first sub-item refers to the owner list view item so to access the actual sub-items you need to index starting at 1. This will return you a ListViewSubItem object and you can get it''s text string by calling ListViewSubItem.Text.


ListViewItem item = new ListViewItem();
item.Subitems.Add,或者如果它是一个集合,则可以获取Item [index] .Subitems.add
ListViewItem item = new ListViewItem();
item.Subitems.Add or if it is a collection you can get Item[index].Subitems.add


这篇关于C#中ListView项的子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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