首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示成员不是在Winforms中的RepositoryLookupEdit中第一次触发事件时显示吗?

显示成员不是在Winforms中的RepositoryLookupEdit中第一次触发事件时显示吗?
EN

Stack Overflow用户
提问于 2013-12-11 05:57:25
回答 1查看 872关注 0票数 1

我在Gridview的第一栏中使用了RepositoryLookupEdit。使用EditValueChanged事件保留的列自动填充,直到现在每件事都很好。然后我在RepositoryLookupEdit中调用一个函数,在这个EditValueChanged事件第一次触发我的显示成员之后,它只显示了我给出的Null值。下一次,如果我重新选择同一列,它可以正常工作。这里出了什么问题?

代码语言:javascript
复制
private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
    {
        GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
        DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();


        gridView1.SetFocusedRowCellValue("Description", SelectedDataRow["ProductDescription"]);
        gridView1.SetFocusedRowCellValue("UoM", SelectedDataRow["UnitofMeasure"]);
        gridView1.SetFocusedRowCellValue("Quantity", SelectedDataRow["DefaultQuantity"]); //UnitPrice
        gridView1.SetFocusedRowCellValue("UnitPrice", SelectedDataRow["MRPPrice"]);
        gridView1.SetFocusedRowCellValue("DiscountPercentage", SelectedDataRow["Discount"]);
        gridView1.SetFocusedRowCellValue("DiscountAmount", SelectedDataRow["DiscountAmount"]);
        gridView1.SetFocusedRowCellValue("TaxInPercentage", SelectedDataRow["Taxid1"]);

        Taxamountcalc(); // function to calculate taxamount

        rowcount = gridView1.RowCount; 
    }

在上面的代码中,如果我移除或注释了"Taxamountcalc()“,那么我的显示成员将正确显示,如果我启用了这个函数,那么它只显示"NullText”。

代码语言:javascript
复制
 private void Taxamountcalc()
    {
        if (barCheckItem1.Checked)
        {
            TaxAmount.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
            TaxAmount.UnboundExpression = "Round([UnitTotal] * ([TaxInPercentage] / 100), 2)";
        }
        else if (!(barCheckItem1.Checked)) 
        {
            TaxAmount.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
            TaxAmount.UnboundExpression = "Round(([UnitPrice] * ([TaxInPercentage] / 100)) * [Quantity], 2)";
        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-16 05:49:42

不要从RepositoryLookupdit EditValueChanged事件调用任何函数。如果我们从EditValueChanged事件调用任何函数,那么第一次从lookupedit显示成员中选择任何值是不显示的,它只是显示空文本。

代码语言:javascript
复制
private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
    GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
    DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();


    gridView1.SetFocusedRowCellValue("Description", SelectedDataRow["ProductDescription"]);
    gridView1.SetFocusedRowCellValue("UoM", SelectedDataRow["UnitofMeasure"]);
    gridView1.SetFocusedRowCellValue("Quantity", SelectedDataRow["DefaultQuantity"]); //UnitPrice
    gridView1.SetFocusedRowCellValue("UnitPrice", SelectedDataRow["MRPPrice"]);
    gridView1.SetFocusedRowCellValue("DiscountPercentage", SelectedDataRow["Discount"]);
    gridView1.SetFocusedRowCellValue("DiscountAmount", SelectedDataRow["DiscountAmount"]);
    gridView1.SetFocusedRowCellValue("TaxInPercentage", SelectedDataRow["Taxid1"]);

    //  Taxamountcalc(); 
    //  rowcount = gridView1.RowCount; 
}

现在它正在正常工作

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20511593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档