I Have to form form1 and form2 and i want to transfer the all selected items of a listbox of Form1 To listbox of Form2 ..Please help me..
Thanks
Shailendra
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shailendra VermaPosted Apr 16, 2010, 2:15 AM
Jaish MathewsPosted Apr 15, 2010, 12:24 PM
//Create a property like below in Form1
public static ListBox.SelectedObjectCollection GetSelectedListItems
{
get;
set;
}
//When need to move to Form2, execute below lines in Form1
GetSelectedListItems = listBox1.SelectedItems;
//From Form2 take values using below code
IEnumerator enumer = Form1.GetSelectedListItems.GetEnumerator();
while (enumer.MoveNext())
{
MessageBox.Show(enumer.Current.ToString());
}