Hey guys, I am having trouble effectively transferring data between forms.
So I have my entry form. It has one button:
private void addBtn_Click(object sender, EventArgs e)
{
string data = string.Format("{0} \t {1} \t {2} \t {3} \t {4} \t {5}",
fnameTxtBox.Text,
lnameTxtBox.Text,
cellNumTxtBox.Text,
landLineTxtBox.Text,
dobPicker.Text,
commentsTxtBox.Text);
Black_Book_2010 myBlack_Book_2010 = new Black_Book_2010();
myBlack_Book_2010.info = data;
myBlack_Book_2010.ShowDialog();
}
So from the top, what this does is gets the data from every txtbox on the form, puts it all into one string, then stores all that information into the "data" variable.
Then I click the button which takes me to my second form. I say, save the "data" variable into the "info" variable on the Black_Book_2010 form.
Heres the Black_Book_2010 form:
At the top i declear a variable I wont to ultimately store the data into
string moreData = "";
Then here is the "info" variable that now has the data:
public string info
{
set
{
moreData = value;
}
}
When the form loads, I wont it to get the "moreData" variable and add it to the listbox:
private void Black_Book_2010_Load(object sender, EventArgs e)
{
data.Items.Add(moreData.ToString());
}
I also have a button on the Black_Book_2010 form, called Add, which would take me back to my data entry form if I wanted to add more data.
But when I fill in the form and click add, my summary form starts again, it doesnt load the previous data, it just opens a new summary form.
What I need is when every I hit add on my data entry form, it adds that data to the existing summary form and not create a whole new one.