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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adjusting formula references when target cell moves

Thread ID:





41993 Mar 16,2006 09:00 PM UTC Mar 20,2006 09:19 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On March 16, 2006 09:00 PM UTC

I know that if you move (through drag-drop) a cell that contains a formula, you guys will handle adjusting the formula for the move. What I need to do is adjust the reference when the target of a formula cell moves. ie: (A1): 45 (B2): =A1 * 2 When I move A1 to D5, then B2''s formula should be "=D5*2". I don''t know if you guys have support for this (It doesn''t seem to happen by default in If you don''t, then what would I have to do to add it myself? I already have code to parse a formula''s arguments and adjust them by an offset. The thing I need help with is how to work with the formula engine (ie: dependendCells and dependendFormulaCells) and the drag-drop engine to make it work. Any ideas would be appreciated. Thanks.

Administrator [Syncfusion]
Replied On March 20, 2006 09:19 AM UTC

Hi Alex, Sorry for the delay in responding to you. Here is the code snippet, to retrieve the dependent Cells and dependent Formula Cells in the grid. // To Retrieve all the cells affected public void DisplayAllAffectedCells() { GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine; foreach(object o in engine.DependentCells.Keys) // foreach(object o in engine.DependentFormulaCells.Keys) { string s1 = o as string; Console.Write(s1 + " affects "); Hashtable ht = (Hashtable) engine.DependentCells[s1]; // Hashtable ht = (Hashtable) engine.DependentFormulaCells[s1]; foreach(object o1 in ht.Keys) { string s2 = o1 as string; Console.Write(s2 + " "); } Console.WriteLine(""); } } Please refer to the AdjustReferencesForRangeChange() and AdjustReferences() methods in the GridFormulaEngine.cs of the source code ( \Windows\Grid.Windows\Src\Extensions\Formulas\GridFormulaCell.cs ) to change the reference in the formula cell. The DragEnter and DragDrop events will help you to get the initial and final position of the cell that is being dragged and dropped. Get the cell that is being dragged ( DragEnter ) and retrieve the dependent formula cells ( above code snippet ) for the respective cell. Also change the references in the formula cells with respect to the newly dropped position of the cell in the grid by using the Drag Drop event. Best regards, Madhan.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon