1

我在 Gridview 的第一列中使用了 RepositoryLookupEdit。使用 EditValueChanged 事件剩余的列会自动填充,直到现在一切正常。然后我在 RepositoryLookupEdit 中调用一个函数,在此 EditValueChanged 事件第一次触发后,我的显示成员没有显示,它只是显示我给定的 Null 值。下次如果我重新选择同一列,它工作正常。这里出了什么问题?

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”。

 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)";
        }
    }
4

1 回答 1

1

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

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; 
}

现在它工作正常

于 2013-12-16T05:49:42.347 回答