父窗体 :包含listview,几个按钮分别是修改,删除,添加
添加窗体:string[] xiugai = {count.ToString(),this.comboBox2.Text,};
((ListView)frm1.Controls["ListView1"]).Items.Insert(count ,new ListViewItem( xiugai)); 是这样添加的;
现在不知道如何选中listview中的某一项并且修改中,求高手解答!
添加窗体:string[] xiugai = {count.ToString(),this.comboBox2.Text,};
((ListView)frm1.Controls["ListView1"]).Items.Insert(count ,new ListViewItem( xiugai)); 是这样添加的;
现在不知道如何选中listview中的某一项并且修改中,求高手解答!
你先把它的值取出来
在修改后
在填充进去就行了
两者的差别就在于占位符位置的不同
//修改按钮操作
private void button6_Click(object sender, EventArgs e)
{
if (listView2.SelectedItems.Count == 1)
{
AddItem frm = new AddItem();
frm.ShowDialog();
if (frm.IName != null)
{
listView2.SelectedItems[0].SubItems[1].Text = frm.IName;
}
}
else
MessageBox.Show("请先选择要修改的某一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}