Tuesday, 17 September 2013

C# - Failing at tranfering data between froms

C# - Failing at tranfering data between froms

I am new to C# and already starting to have some troubles. I have googled
for some hours how to get this done but my program refuses to obey his
master.
My MainForm has a ListBox. Form2 uses a Open File Dialog and should return
the file path to the ListBox in MainForm
This is the code I have in Form2
public void BrowseFileDialog_FileOk(object sender, CancelEventArgs e)
{
string path = BrowseFileDialog.FileName;
MainForm frm = new MainForm();
frm.AppListAdd(path);
}
This is the MainForm
public void AppListAdd (string path)
{
AppList.Items.Add(path);
}
Note: AppList = ListBox
I don't get any error, yet the ListBox remains empty. Thanks for any help.

No comments:

Post a Comment