Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Questions on adding UnboundField
posted

Hello

I have a few questions regarding data binding on the XamDataGrid.

Lets say I set the DataSource to be an object of type List<Item> where Item is a class that has a number of public properties.

I want to add two extra columns in the grid:

1. The first column is simply a row counter and shows the number of the row. It has nothing to do with the Item class. I simply want an extra column called "Item Number" where each cell takes it's value from the grid.Row.Index (or whatever grid property gives me the row index).

2. The second column is an unbound column (i.e. not a public property in the Item class) that has the value calculated by applying a formula on the values of other cells in that row (i.e. public properties on Item). For example, I want a column called "Net Price" where the value is calculated by getting the Item.Price and multiplies it with the Item.Quantity.

Could someone explain to me how I can do this? Could you please provide me with code examples on exactly what events I have to override on the grid (or any of it's properties) to achieve this?

I can set the

XamDataGrid.FieldLayoutSettings.AutoGenerateFields = false

and then override the

XamDataGrid.FieldLayoutInitialized

event and programatically create the Fields (side-question: is Field the equivalent of Column in the WinForms UltraGrid??), but I do not really understand how to achieve 1. and 2. above.

Many thanks

Kostas