I’m trying to create multiple form instances. For example, i have a form1 and form2
and there is a ListView in form1.
When ever clicked the item in ListView , it will create a new instance of form2.
Form2 listview1.FocusedItem.SubItems[0].Text = new Form2();
listview1.FocusedItem.SubItems[0].Text.Show();
But C# don’t allow me to do that, any idea? (yes.. i got errors 😀 )
Ok, the idea is .. let say i want to have 3 instances of form2,
Form2 f21 = new Form2();
Form2 f22 = new Form2();
Form2 f23 = new Form2();
and now I’ll have 3 form2, but what if i don’t know how many form[s] i might create ? (create form base of the items in listview dynamically)
Actually this maybe not the right way to do it … Any solution is appreciated.
listview1.FocusedItem.SubItems[0].Textis astringproperty, you can not assignSystem.Windows.Forms.Formtostring.not very clear what you’re going to achieve here, but, may be something like this
on click of the item would be enough for you.
If it’s not what you’re asking for, please clarify.
EDIT
To manage arbitrary quantity of forms, you can do something like:
and on click on item:
The other thing to mantion it that may be you will need to find some specific form in the collection (for some reason). You can assign some special property to Form2, some unique identifier, in order to be able to find it after, on request.