问题描述
大家好,
我有一个Parent Form QuotationDetails,其中有一个名为 ChooseCustomer 的按钮,当我点击它时打开名为CustomerSearchForm的表单。现在有一个Datagridview CustomerSearchForm,带有两个按钮确定并取消。因此,当我从DGV中选择一行并单击确定时,该行中的所有详细信息都将填入QuotationDetails(选定的客户客户数据。我写了所有代码及其工作正常。但问题是我这样做是通过关闭父表单QuotationDetails并打开它的新实例。但是我需要的是显示父表单并更新来自Childform的文本框。
以下是从ChildForm加载客户详细信息的代码
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];
this.Close();
objQM.tabQuotationManagement.SelectedIndex = 1;
objQM.Show();
}
我已经搜索了一个解决方案并得到了一个使用Event和一个代表触发它的想法。
但是我不确定如何在我的方案中实现相同的方法。
请指教。
谢谢。
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.
推荐答案
这篇关于从子窗体中的Datagridview更新父窗体中的所有文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!