DataTable Expression Column

G

Guest

My DataGrid is bound to a DataSet, with following columns: Description, CashExp, CreditExp,Frequency

On run time, I am adding two new DataColumn “AnnualCash†and “AnnualCredit†and defining Expression property to give product of two columns, as follows

Dim dc As DataColumn
dc = New DataColumn("AnnualCash", GetType(System.Single))
dc.Expression = " CashExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

dc = New DataColumn("AnnualCredit", GetType(System.Single))
dc.Expression = " CreditExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

The only problem I am getting is when CashExp or CreditExp or Frequency is changed the value of derived column is not changed (calculated) until user changes the row either by tab or arrow keys.

How can I change this behaviour so that the derived columns gets calculated when user edit values in a cell.

I have scoured through stacks of websites, posted to stacks of discussion forum, but no one seems to have a slightest clue about it.

Does that mean I have to ask my user to make sure to change the row, in order to get correct results?
 
C

Cor Ligthert

Hi PankajBanga

Add this on the right place where it is needed to force that what you want.

BindingContext(mydataset.Tables("ClientExpenses")).EndCurrentEdit()

I hope this helps?

Cor

My DataGrid is bound to a DataSet, with following columns: Description, CashExp, CreditExp,Frequency

On run time, I am adding two new DataColumn "AnnualCash" and
"AnnualCredit" and defining Expression property to give product of two
columns, as follows
Dim dc As DataColumn
dc = New DataColumn("AnnualCash", GetType(System.Single))
dc.Expression = " CashExp * Frequency"
myDataSet.TablesColumns.Add(dc)

dc = New DataColumn("AnnualCredit", GetType(System.Single))
dc.Expression = " CreditExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

The only problem I am getting is when CashExp or CreditExp or Frequency is
changed the value of derived column is not changed (calculated) until user
changes the row either by tab or arrow keys.
How can I change this behaviour so that the derived columns gets
calculated when user edit values in a cell.
I have scoured through stacks of websites, posted to stacks of discussion
forum, but no one seems to have a slightest clue about it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top