DevExpress Lookupedit设置选定值

时间:2014-05-22 10:00:22

标签: c# devexpress devexpress-windows-ui

我有以下网格,它在Win Form Load事件中填充InquiryDetails enter image description here

private void frmInquiryManagement_Load(object sender, EventArgs e)
        {

            InquiryService inquiry = new InquiryService();
            clearGetInquiry();

            DataTable dt = InfoPCMS.db.executeSelectQuery("select * from Inquiry");
            gridInquiryList.DataSource = dt;

            DataTable dt2 = InfoPCMS.db.executeSelectQuery("select * from Customer");
            txtCustomer.Properties.DataSource = dt2;
            txtCustomer.Properties.ValueMember = "Id";
            txtCustomer.Properties.DisplayMember = "CustomerName";
            txtCustomer.Properties.NullText = "Please Select Customer";

            txtCustomer.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CustomerName"));
            txtCustomer.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Address"));
            txtCustomer.Properties.ShowHeader = false;

            int nextid = inquiry.getNextId();
            txtInquiryNo.Text = nextid.ToString();
        }

通过双击一行,它会搜索所有详细信息并显示在“获取查询”选项卡中,如下所示,代码位于图像下方

enter image description here

private void selectInquiry(object sender, EventArgs e)
        {


            btnAddInquiry.Enabled = false;
            btnUpdate.Enabled = true;
            txtInquiryNo.Enabled = false;


            String inquiryno = gridView1.GetFocusedDataRow()["InquiryNumber"].ToString();

            InquiryService inquiry = new InquiryService();
            inquiry = inquiry.searchInquiry(inquiryno);
            if (inquiry != null)
            {

                txtInquiryNo.Text = inquiry.InquiryNumber.ToString();
                //txtDate.Text = inquiry.InquiryDate;
                txtDate.Text = InfoPCMS.conversion.convertDate(inquiry.InquiryDate);

                txtCustomer.EditValue = inquiry.CustomerID.ToString();
                txtInquiryTaken.Text = inquiry.InquiryTaken;
                txtInspectionDetails.Text = inquiry.InspectionDetails;
                txtProblemNature.Text = inquiry.ProblemNature;
                txtProblemSource.Text = inquiry.ProblemSource;
                txtSiteResponsible.Text = inquiry.SiteResponsible;
                txtQuotationNo.Text = inquiry.QuotationNumber.ToString();
                txtFollowupDetails.Text = inquiry.FollowupDetails;
                txtInspectionDone.Text = inquiry.InspectionDone;

                tabInquiryManagement.SelectedTabPage = xtraTabPage2;

            }
            else
            {

                MessageBox.Show(InfoPCMS.message.GET_NO_SUCH_RECORD_INFORMATION(), "Information");

            }
        }

第一次搜索它工作正常,但是当你清除所有字段和页面并尝试另一条记录后,它会将所有记录但Lookupedit值提供给它的null状态,如下所示,

enter image description here

private void clearGetInquiry() {

            txtInquiryNo.Text = "";
            txtDate.Text = "";
            txtCustomer.EditValue = null;

            txtInquiryTaken.Text = "";
            txtInspectionDetails.Text = "";
            txtProblemNature.Text = "";
            txtProblemSource.Text = "";
            txtSiteResponsible.Text = "";
            txtQuotationNo.Text = "";
            txtFollowupDetails.Text = "";
            txtInspectionDone.Text = "";

            btnAddInquiry.Text = "Add Inquiry";

            InquiryService inquiry = new InquiryService();
            int nextid = inquiry.getNextId();
            txtInquiryNo.Text = nextid.ToString();

            tabInquiryManagement.SelectedTabPage = xtraTabPage1;

            btnAddInquiry.Enabled = true;
            btnUpdate.Enabled = false;
            txtInquiryNo.Enabled = true;

        }

如何摆脱这个问题? (即使您在进入“获取查询”标签后进行搜索,也会发生这种情况。

0 个答案:

没有答案