简体   繁体   English

如何在C#中将所选项目从一个列表视图移动到另一个列表视图?

[英]How to move selected item from one listview to another in C#?

我在我的列表视图上使用FullRowSelect = true,如何将一种形式的列表视图项转移到具有列表视图的另一种形式。

on form1 , create a ListViewItem as form1 ,创建一个ListViewItem作为

ListViewItem lstItem = listView1.SelectedItems[0];

on form2 , create a parameterized constructor as form2 ,创建一个参数化的构造函数为

ListViewItem lstViewItem = new ListViewItem(); //global variable
public Form2(ListViewItem lstItem)
{
    InitializeComponent();
    lstViewItem = lstItem;
}

call form2 from form1 with ListViewItem as 使用ListViewItemform1调用form2

Form2 frm = new Form2(lstItem);
frm.Show();

so on form2 you can get ListViewItem which was selected and pass through form1 因此在form2您可以获得选择的ListViewItem并通过form1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM