简体   繁体   中英

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

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

on form1 , create a ListViewItem as

ListViewItem lstItem = listView1.SelectedItems[0];

on form2 , create a parameterized constructor as

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

call form2 from form1 with ListViewItem as

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

so on form2 you can get ListViewItem which was selected and pass through form1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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