Updating Parent Form Textboxes from Child Form Datagridview Selected Row

Posted by Nkkppp under C# on 2/13/2013 | Points: 10 | Views : 1359 | Status : [Member] | Replies : 0
Hi All,

I have a Parent Form QuotationDetails in which I have a button called ChooseCustomer and when I click it a child form named CustomerSearchForm is opened.Now there is a Datagridview CustomerSearchForm with two button OK and CANCEL.So when I select a Row from the DGV and Click OK all the details from that row are filled in the QuotationDetails (around 20 Textboxes) with the selected customer Customer data.I have written all the code and its working fine.But the problem is I am doing this by closing the Parent form QuotationDetails and opening a new instance of it.But the requirement is I need to display the Parent form and update the Textboxes from Childform.

Below is the Code for Loading Customer Details from ChildForm

public void btnLoadCustomerDetails_Click(object sender, EventArgs e)
QuotationManagement objQM = new QuotationManagement();
string[] Details = new string[gvCustomerDetails.SelectedRows[0].Cells.Count];
for (int i = 1; i < gvCustomerDetails.SelectedRows[0].Cells.Count; i++)
Details[i] = gvCustomerDetails.SelectedRows[0].Cells[i].Value.ToString();
objQM.txtCustomerdetails.Text = Details[3] + Environment.NewLine + Details[4] + "," + Details[5] + "," + Details[6] + "," + Details[7];
objQM.txtcustContact.Text = Details[3];
objQM.txtCustPhoneno.Text = Details[10];
objQM.txtfaxNo.Text = Details[12];
objQM.txtCustMobile.Text = Details[15];
objQM.txtcustemail.Text = Details[14];
objQM.txtCustWeb.Text = Details[16];
objQM.txtcustsource.Text = Details[29];
objQM.txtCustActivestatus.Text = Details[27];
objQM.txtCustomerType.Text = Details[44];
objQM.txtCustNomAccType.Text = "Customer Quotations";
objQM.txtCustAccStatus.Text = Details[25];
objQM.txtTerms.Text = Details[31];
objQM.txtCurrency.Text = Details[33];
objQM.txtcountryname.Text = Details[9];
objQM.lblCustomermasterId.Text = Details[0];
objQM.tabQuotationManagement.SelectedIndex = 1;

I have searched for a solution and got an Idea to use Event and a Delegate to trigger it.

But I am not sure how to implement the same in my scenario.

Please advise.

Thank you.


(No response found.)

Login to post response