积极答复者
ListView中的item怎么设置装箱拆箱操作绑定实体类?

问题
答案
-
ListView的每个子项都是ListViewItem对象的,你可以间接去构建实体类,例如代码如下:
// 通过获取子项的属性来构建一个Info对象 // 下面采用了对象构造器的方式来构造一个对象 Info user =new Info {Name=this.ListView1.SelectedItem[0].SubItems[0].Text,Tag = this.ListView1.SelectedItem[0].SubItems[1].Text};
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. My sample
- 已标记为答案 Jason Dot WangModerator 2013年9月23日 1:33
全部回复
-
ListViewItem构造函数第一个传入String,后面是图标项索引。我建议:
1)用一个List<T>填充(比如Info类)。
2)绑定到ListView中。
3)图标指定,可以用ImageIndex设置某个项索引图标。
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
ListView的每个子项都是ListViewItem对象的,你可以间接去构建实体类,例如代码如下:
// 通过获取子项的属性来构建一个Info对象 // 下面采用了对象构造器的方式来构造一个对象 Info user =new Info {Name=this.ListView1.SelectedItem[0].SubItems[0].Text,Tag = this.ListView1.SelectedItem[0].SubItems[1].Text};
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. My sample
- 已标记为答案 Jason Dot WangModerator 2013年9月23日 1:33