The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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 4.1.0.50). 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.
ADAdministrator Syncfusion Team 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.