I am working on a program that has a listView box in the main form and when a user selects add item it will pop open a new form that has pick lists and of dependent drop downs as well as text boxes. I want to keep the second form open so the user can keep adding material to the list in the main form. I have done something similar before but it was dependent on the close of the second form to add the item to a text box on the main. Below is a sample of my code so far.
This is the code for the button click to add material
private void button6_Click(object sender, EventArgs e)//Material selection
{
MaterialSelection myForm2 = new MaterialSelection();
myForm2.ShowDialog();
myForm2.Dispose();
textBox2.Text = myForm2.matselected;//gets selected material from mat form
}
This is the code at the start of the popup form
public string matselected//add class to get selected mat on close
{
get { return listBox3.Text; }
}
In the new I did this
public string memlist
{
get { return memlist; }
}
This code is from another program that I have and it works on close but I want to add the items to a list in another open form. When I add this code it gives me the following error.
Error 2 An object reference is required for the non-static field, method, or property 'programname.AddItem.memlist.get'
Any push in the right direction will be greatly appreciated.

New Topic/Question
Reply




MultiQuote





|