Hi guys.
What I'm trying to do is pass all items and subitems from a listview on my main form to a listview on a new form.
After googling for a couple of hours the closest I got was the the code below which only passes the selected Item from my main form to the new form, but I can't figure out how to send all of them.
I can see that this >> "Main_Form_ListView.FocusedItem.Clone(); }" is where I'm getting stuck but can't work out what I need to change it to.
Main Form
public MainForm()
{
InitializeComponent();
}
public ListViewItem _MainForm_Listview
{
get { return (ListViewItem)Main_Form_ListView.FocusedItem.Clone(); }
}
private void MainForm_Load(object sender, EventArgs e)
{
ListViewItem item = Main_Form_ListView.Items.Add("First");
item.SubItems.Add("First");
ListViewItem item2 = Main_Form_ListView.Items.Add("Second");
item2.SubItems.Add("Second");
}
private void button1_Click(object sender, EventArgs e)
{
SecondForm SecondForm = new SecondForm(this);
SecondForm._listView = _MainForm_Listview;
SecondForm.ShowDialog();
SecondForm.Dispose();
}
}
Second Form
public SecondForm(MainForm parentForm)
{
InitializeComponent();
}
public ListViewItem _listView
{
set
{ Second_Form_ListView.Items.Add(value); }
}
}
What do I need to change so that it passes ALL Items/Subitems to the listview on the second form.