We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Formula Range Refresh in GridDatabound Grid

Hi, I have a formula column in a GridDataBoundGrid. If a cell has a formula =sum(c1:c4) and a row is inserted at index 2 by adding a datarow to the datasource. How can i refresh this formula =sum(c1:c5) Regards Vinay

6 Replies

AD Administrator Syncfusion Team March 21, 2005 01:18 PM

If you are cacheing the GridFormulaTags in grid.model.SaveCellInfo, then try setting these properties: this.engine = ((GridFormulaCellModel)gridControl1.Model.CellModels["FormulaCell"]).Engine; engine.FormulaCopyFlags |= GridFormulaCopyFlags.InsDelRangeReferencesUpdated; engine.FormulaCopyFlags |= GridFormulaCopyFlags.ClipBoardReferencesAdjusted;


VI Vinay March 21, 2005 05:53 PM

Hi The formula range does not refresh even after setting the copyformulaflags. The formula gets computed (i,e the new computed value is shown on the grid) but the range in the formula does not change Sum(c1:c4) continues to stay at sum(c1:c4) when it should have changed to sum(c1:c5) Regards Vinay


AD Administrator Syncfusion Team March 21, 2005 07:56 PM

In order for the grid to update the references for inserted/deleted rows, the grid has to be a GridControl (non-virtual). The reason is the grid has to have direct access to the data. The data has to be stored in the grid.Data object for this to happen. In a GridDataBoundGrid where you manage the data, the grid cannot make these changes for you. So, you will have to make these adjustments. If you change to a GridControl that holds the data, then the grid can do this for you.


VI Vinay March 22, 2005 07:05 AM

Hi, Can i use a virtual grid to solve this problem (moreover i am using an arraylist as the datasource). In case i use the virtual grid do i have cache the formula tags. Regards Vinay


AD Administrator Syncfusion Team March 22, 2005 07:15 AM

If you use a true virtual grid, then you will have to maintain the FormulaTags. Exactly what is your purpose in trying to use an arraylist? Could you not just populate the gridControl directly in the same manner as you are populating the ArrayList?


VI Vinay March 22, 2005 07:46 AM

Hi, I have created a control inheriting ur grid control which accepts an arraylist as the datasource. I have to store the formula entered in the formula cell in one of the object properties stored in the arraylist and the computed value in another property. Only the Formula prperty has been binded to the grid. Using reflection i am setting the computed value in the savecellinfo event. Is there anyway i could rebuild the arraylist reading the data in the grid if i use the virtual grid technique(i.e including the formula and the computed value). Regards Vinay >If you use a true virtual grid, then you will have to maintain the FormulaTags. > >Exactly what is your purpose in trying to use an arraylist? Could you not just populate the gridControl directly in the same manner as you are populating the ArrayList?

Loader.
Live Chat Icon For mobile
Up arrow icon