Shantnu Ojha

Shantnu Ojha

  • NA
  • 19
  • 644

how to transfer data between form in wpf without opening new

Jun 17 2016 2:50 PM

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 :

FORM1:  
private void txtSellerCode_GotFocus(object sender, RoutedEventArgs e) 
{ 
SelectSeller frmSelectSeller = new SelectSeller();         
frmSelectSeller.Show(); this.Hide(); 
}  
FORM2: 
private void SelectBtn_Click(object sender, RoutedEventArgs e) 
{ 
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(); 
}

Answers (2)