using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace pf { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void lvShow_SelectedIndexChanged(object sender, EventArgs e) { } private void lvShow_DoubleClick(object sender, EventArgs e) { Form2 frm = new Form2(); frm.name = lvShow.SelectedItems[0].SubItems[1].Text; ListViewItem selectRow = lvShow.SelectedItems[0]; frm.myitem = selectRow; frm.Show(); } private void Form1_Load(object sender, EventArgs e) { InitData(); foreach (UserInfo item in users) { ListViewItem lvitems = new ListViewItem(item.id); lvitems.SubItems.Add(item.Name); lvitems.SubItems.Add(item.Age.ToString()); lvitems.SubItems.Add(item.assess); lvitems.SubItems.Add(item.Score.ToString()); lvShow.Items.Add(lvitems); } } UserInfo[] users = new UserInfo[3]; private void InitData() { users[0] = new UserInfo(); users[0].id = "001"; users[0].Name = "张三"; users[0].Age = 12; users[1] = new UserInfo(); users[1].id = "002"; users[1].Name = "李四"; users[1].Age = 22; users[2] = new UserInfo(); users[2].id = "003"; users[2].Name = "呵呵"; users[2].Age = 2; } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace pf { public partial class Form2 : Form { public Form2() { InitializeComponent(); } public string name; public ListViewItem myitem; private void Form2_Load(object sender, EventArgs e) { textBox1.Text = name; textBox2.Text = myitem.SubItems[3].Text; textBox3.Text = myitem.SubItems[4].Text; } private void button1_Click(object sender, EventArgs e) { myitem.SubItems[3].Text = textBox2.Text; myitem.SubItems[4].Text = textBox3.Text; this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Hide(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace pf { public class UserInfo { public string id { get; set; } public string Name { get; set; } public int Age { get; set; } public string assess { get; set; } public int Score { get; set; } } }