I am trying to add text to a listbox by using a string type variable. During debug I noticed that the variable had the text I wished to add to the listbox, but the listBox1.Items.Add(s_Text); didnt' do anything. Is there a different way your supposed to do this

Adding text to a listbox
pgoel6uc
kostrin
patag2001
SteveMo
KitGreen
Vaish
ok the problem is simple. The user creates another main form instance in the other form "Add Items" and adds items to this new main form instance - this will not work. It will continue to operate but since the original existing main form is "alive", you are not dealing/handling with it but creating a new instance (another instance) of the main form.
You need to reference the main form into this "Add Items" form and add the items as you have done in the code snippet:
frmMain
mainForm = new frmMain(); //this needs to be taken out MessageBox.Show("" + i_currentItem); MessageBox.Show("Item Name: " + newItem.Get_itemName());mainForm.Set_item(newItem, mainForm.Get_numItems());
So, read the thread below on how to pass a reference of an object, your main form in this case, to this "Add Items" form, then simply access it (access the main form) in the "Add Items" form to add the items to the main form:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=729974&SiteID=1 (around the 2nd/3rd response of mine with a code snippet)
Tom McAnnally
should be:
this.listBox1.Items.Add(theTextBox.Text);
textboxes are controls, to get or set its textual property, use the "Text" property of the textbox control and most text based controls (combobox, label, textbox etc...)
Steve Hempen