Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I m transferring data from one WPF Window form (Form1) to another WPF Window form (Form2). but every time i transfer data from Form2 to Form1 i have to close and open Form1.

Please tell me alternate method so that i can transfer data without closing and openning the Form1

Here is my code :

What I have tried:

DataRowView drv = (DataRowView)dataGridSeller.SelectedItem;
clsCreateInvoice.S_ID = int.Parse(drv["B_ID"].ToString());
clsCreateInvoice.S_Code = drv["B_Code"].ToString();
clsCreateInvoice.S_Name_Address = drv["B_Name"].ToString() + " ," + drv["B_Address_1"].ToString() + " ," + drv["B_Address_2"].ToString();

CreateInvoice frmCreateInvoice = new CreateInvoice();
frmCreateInvoice.txtSellerCode.Text = drv["B_Code"].ToString();
frmCreateInvoice.lblSellerNameAddress.Text = drv["B_Name"].ToString() + " ," + drv["B_Address_1"].ToString() + " ," + drv["B_Address_2"].ToString();
frmCreateInvoice.Show();
this.Hide();
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jun-16 15:14pm    
Here is the alternative method: don't close and open your form. :-)
No seriously: I have no idea what makes you closing the form, and so on.
By the way, this is WPF, so it's not the "form", it's a Window.
And don't use string concatenation, use string.Format...
—SA
Shantnu Ojha 20-Jun-16 5:00am    
Doesn't Work ....

See Article...
http://stackoverflow.com/questions/37886702/update-data-in-opened-wpf-window-form/37889062#37889062
Sergey Alexandrovich Kryukov 20-Jun-16 9:02am    
"Doesn't work" is not informative. Did you run it under the debugger? do you know what exactly happens?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900