C#选择listview显示的一行,点击button弹出一个可编辑窗口(可以对listview选定的那行进行修改)求代码

如题所述

  ///
  ///Form1
  /// 
         private void button1_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            int a = listView1.FocusedItem.Index;//获取当前选择项索引
            for (int i = 0; i < 5;i++ )
            {
                frm.str[i] = this.listView1.Items[a].SubItems[i].Text;
            }
            
            frm.ShowDialog();
        }
        
        ///
        ///Form2
        ///
         public string[] str = new string[5];
        
        public Form2(Form1 frm ;)
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = str[0];
            this.textBox2.Text = str[1];
            this.textBox3.Text = str[2];
            this.textBox4.Text = str[3];
            this.textBox5.Text = str[4];
        }

Form2 用来显示 选择项的值  修改后保存

温馨提示:内容为网友见解,仅供参考
无其他回答