项目经理评分系统
1.是否选中一行:
1.首先:定义一个SE一个辅助类:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace thorought.NET.xiangm { public class SE { //工号 private int number; public int Number { get { return number; } set { number = value; } } //年龄 private int age; public int Age { get { return age; } set { age = value; } } //姓名 private string name; public string Name { get { return name; } set { name = value; } } //性别 private char sex; public char Sex { get { return sex; } set { sex = value; } } //人气值 private int Popularity; public int Popularity1 { get { return Popularity; } set { Popularity = value; } } //项目经理年度评分 private string grade; public string Grade { get { return grade; } set { grade = value; } } //经理评分 private int manager; public int Manager { get { return manager; } set { manager = value; } } } }
2.建立主窗口
3.创建SE的自定义数组:
//定义数组
public SE[] en = new SE[3];
给SE里面的值附上初始值:
public void Init() { SE SB = new SE(); SB.Number = 11; SB.Name = "离散"; SB.Age = 26; SB.Grade = "为评价"; SB.Manager = 0; en[0] = SB; //2 SE SB1 = new SE(); SB1.Number = 12; SB1.Name = "阿达"; SB1.Age = 22; SB1.Grade = "未评价"; SB1.Manager = 0; en[1] = SB1; //3 SE SB2 = new SE(); SB2.Number = 13; SB2.Name = "释放"; SB2.Age = 25; SB2.Grade = "未评价"; SB2.Manager = 0; en[2] = SB2; }
4.遍历绑定ListView中
public void UpdateView()
{
foreach(var item int en)
{
ListViewItem list = new ListViewItem(item.Nunber.Tostring());
list.SubItems.Add(item.Name);
list.SubItems.Add(item.Age.ToString());
list.SubItems.Add(item.Grade);
list.SubItems.Add(item.Manager.ToString());
listView1.Items.Add(list);
}
}
5.放到主窗口里去:
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { //对选中的是一整行 ListViewItem item = listView1.SelectedItems[0]; FrmJudge fm = new FrmJudge(); fm.item = item; fm.Show(); }
6.在第二个窗口上:
//定义一个公共的变量
public ListViewItem item = null;//获取整行的信息
//
//主窗口 private void FrmJudge_Load(object sender, EventArgs e) { this.txtName.Text = item.SubItems[1].Text;//绑定名字文本ku txtName.ReadOnly = true;//只读 } //评分按钮 private void btngrade_Click(object sender, EventArgs e) { item.SubItems[3].Text = this.txtgrade.Text.Trim(); item.SubItems[4].Text = this.txtevaluate.Text.Trim(); this.Close();