2013-12-11 78 views
1

我在Gridview的第一列中使用了RepositoryLookupEdit。使用EditValueChanged事件剩余列自动填充,直到现在,每件事情都正常工作。然后我在RepositoryLookupEdit中调用一个Function,在第一次这个EditValueChanged事件触发我的显示成员后,它不显示,它只是显示我给出的空值。下次如果我重新选择相同的列它工作正常。这里有什么问题?显示成员在Winforms Gridview Devexpress的RepositoryLookupEdit中第一次触发事件时不显示?

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

你能否提供一些代码? – SidAhmed

+0

嗨锡德,我更新了我的问题。 – Srihari

+0

谢谢,你能添加TaxAmountCalc()方法的代码吗? – SidAhmed

回答

1

不要从RepositoryLookupdit EditValueChanged事件中调用任何函数。如果我们从EditValueChanged事件调用任何函数,对于第一次从lookupedit显示的成员不显示任何值,它只显示nulltext。

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

现在可以正常工作

相关问题