未绑定表达式不在运行时计算winforms devexpress?

时间:2014-04-20 11:03:24

标签: c# winforms gridview devexpress

我在运行时创建了gridview,并在运行时创建了附加的数据源。创建新列并在该列上分配未绑定表达式。当我运行这个我只有空列。帮我解决这个问题。 这是我的代码

OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT InvoiceId, InvoiceNumber, InvoiceDate, Customername AS CustomerId, (Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS Customer_Name, Tax, GrandTotal, CompanyId, InvoiceStatus FROM NewInvoice_1 WHERE CompanyId=" + TXE_CompId.Text + " ", connection);
DataSet sourceDataSet = new DataSet();
adapter.Fill(sourceDataSet);
gridControl1.DataSource = sourceDataSet.Tables[0];

gridView1.Columns.Add(new DevExpress.XtraGrid.Columns.GridColumn()
   {
       Caption = "Total",
       FieldName = "Total",
       VisibleIndex= 3 ,
       UnboundType = DevExpress.Data.UnboundColumnType.Decimal,
       UnboundExpression = "Round([GrandTotal] - [Tax]), 2)"
   });

这是我的输出屏幕 enter image description here

1 个答案:

答案 0 :(得分:2)

你看过documentation了吗? Round方法不需要两个参数。

只需要一个参数。试试这个

UnboundExpression = "Round([GrandTotal] - [Tax])"