Maybe there's a better way to handle child forms, but the functionality I'm trying to create is :
- A main form can create multiple instances of a child form.
- A list of the child forms is maintained in a ListBox on the main form.
- The main form can access child form properties by clicking one of the child form names in the ListBox.
The problem is forms are added to the ListBox, the list grows and I can select forms in the list, but the ListBox has no text. Normally when adding objects to a ListBox, text from the the ToString method is displayed in the list. My forms have a ToString method, but the text doesn't show in the ListBox. Any suggestions?
CPosted Apr 3, 2009, 3:23 PM
Your suggestion gets the name of the form in the ListBox, but it does not create a reference to the Form itself. Normally when adding an object to a ListBox, you can reference the object's properties or methods with something like
myListbox[0].Property;
myListbix[0].Method();
Adding the Form's Text to a ListBox will show the name in the ListBox, but can't acces the Form's methods or properties.
Any other suggestions?
StefanPosted Mar 27, 2009, 4:42 PM
For example: listBox1.Items.Add(childForm1.Text);