本人想做的是选中ListView,然后另一个Label控件显示选中ListView的item的文本,相关代码如下:
public ArrayList SkillList = new ArrayList(); private Character ShirouEmiya = new Character(); class Character { public string Name; public int Level; public int MaxHP; public int MaxMP; public int HP; public int MP; public int Atk; public int Def; public int M_Atk; public int M_Def; public int Agi; public int Potency; public ArrayList SkillList = new ArrayList(); } class Skill { public int Id; public string Name; public int Type; public int EXP; public int MaxEXP; public int Level; } private void ShirouEmiya_Load() { Skill Trace = new Skill(); ShirouEmiya.SkillList.Add ( "投影"); ShirouEmiya.SkillList.Add("料理"); } private void ShirouEmiyaSkillDataLoad() { for (int i=0; i<ShirouEmiya.SkillList.Count; i++) { SkillListView.Items.Add(ShirouEmiya.SkillList[i].ToString ()); } for (int i = 0; i < SkillListView.Items.Count; i++) { if (SkillListView.Items[i].Text.Contains("投影") == true) { SkillListView.Items[i].ForeColor = Color.DarkGray ; } if (SkillListView.Items[i].Text.Contains("料理") == true) { SkillListView.Items[i].ForeColor = Color.DarkGray; } } }
想用来显示ListView文本的label控件名为:SkillNameLabel
解决方案
40
这代码写的好无语啊