创建MyOffice项目
Posted 晨曦-荒微凉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建MyOffice项目相关的知识,希望对你有一定的参考价值。
创建查看评分窗体(FrmLOOK),添加定义成员数组,将员工数据绑定到FrmLOOK窗体的ListView控件上
public ListViewItem lv; private void Form1_Load(object sender, EventArgs e) { string sename = lv.SubItems[1].Text; txtsename.Text = sename; } private void btnexit_Click(object sender, EventArgs e) { this.Close(); } private void btnok_Click(object sender, EventArgs e) { if (isnull() == true) { string suggest = txtwritesuggest.Text; int suggestscore = 0; try { suggestscore = Convert.ToInt32(txtpmscore.Text); } catch (Exception) { MessageBox.Show("请正确输入!"); } lv.SubItems[3].Text = suggest; lv.SubItems[4].Text = suggestscore.ToString(); } this.Hide(); } public bool isnull() { if (txtwritesuggest.Text.Equals(string.Empty)) { MessageBox.Show("请填写评价"); this.txtwritesuggest.Focus(); return false; } else if (txtpmscore.Text.Equals(string.Empty)) { MessageBox.Show("请填写评分"); this.txtpmscore.Focus(); return false; } else { return true; } }
public LOOK() { InitializeComponent(); fuzhi(); zhanshi(); } public SE[] user = new SE[3]; private void LOOK_Load(object sender, EventArgs e) { } public void fuzhi() { SE a = new SE(); a.Id = "111"; a.Name = "王小毛"; a.Age = "26"; a.appraise = "未评价"; a.Scoer = "0"; user[0] = a; SE a1 = new SE(); a1.Id = "112"; a1.Name = "周新宇"; a1.Age = "22"; a1.appraise = "未评价"; a1.Scoer = "0"; user[1] = a1; SE a2 = new SE(); a2.Id = "113"; a2.Name = "张硕"; a2.Age = "23"; a2.appraise = "未评价"; a2.Scoer = "0"; user[2] = a2; } public void zhanshi() { for (int i = 0; i < user.Length; i++) { ListViewItem lv=new ListViewItem(); lv.Text = user[i].Id; lv.SubItems.Add(user[i].Name); lv.SubItems.Add(user[i].Age.ToString()); lv.SubItems.Add(user[i].appraise); lv.SubItems.Add(user[i].Scoer.ToString()); listVi.Items.Add(lv); } } private void listVi_SelectedIndexChanged(object sender, EventArgs e) { } private void listVi_DoubleClick(object sender, EventArgs e) { ListViewItem lvlistitem = listVi.SelectedItems[0]; Form1 frm = new Form1(); frm.lv = lvlistitem; frm.Show(); } } }
public class SE { public string Id { get; set; } public string Name { get; set; } public string Age { get; set; } public string appraise { get; set; } public string Scoer { get; set; } public string Senum { get; set; } }
以上是关于创建MyOffice项目的主要内容,如果未能解决你的问题,请参考以下文章