0

I've a C#/WPF application in which I'm using WorkbookView control.I'm using Spreadsheetgear inside my app.

I've cells A and B in my worksheet.On updating value in A, I need to do some calculations and update value in cell B. The problem is that using the code below, I'm not getting the latest updated value of cell A. For e.g.let's say the current value of A is 1.User changes its value to 2 and wbvOverride_CellBeginEdit method gets invoked. In this method,am always getting value as 1 instead of the new value 2.

What am I missing here please?

Here's my code.

Thanks.

ViewModel:

public void wbvOverride_CellBeginEdit(object sender, SpreadsheetGear.Windows.Controls.CellBeginEditEventArgs e)
{
    SpreadsheetGear.Windows.Controls.WorkbookView sheet = sender as SpreadsheetGear.Windows.Controls.WorkbookView;
    string tempValue = sheet.ActiveCell.Worksheet.Cells[2, 7].Value'
}

XAML:

<Controls:WorkbookView x:Name="wbvOverride" HorizontalAlignment="Stretch" Margin="1" Grid.Row="2" VerticalAlignment="Stretch" ShowError="workbookView_ShowError"  >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="CellBeginEdit">
                    <ei:CallMethodAction MethodName="wbvOverride_CellBeginEdit" TargetObject="{Binding}" />
                </i:EventTrigger>        
        </i:Interaction.Triggers>
</Controls:WorkbookView>
Jimmy
  • 2,106
  • 12
  • 39
  • 53
  • 1
    What if you handle the CellEndEdit event instead of the CellBeginEdit event?: https://www.spreadsheetgear.com/support/help/spreadsheetgear.net.7.0/SpreadsheetGear2012.Windows.WPF~SpreadsheetGear.Windows.Controls.WorkbookView~CellEndEdit_EV.html – mm8 Feb 15 '17 at 20:21
  • CellBeginEdit fires when you initially enter "edit mode" for a cell. You would need to hook into the CellEndEdit(...) event and access the CellEndEditEventArgs.Entry property to get the user-entered value that was committed for the active cell. That aside, you don't say what sort of "calculation" you are doing, but can you not just use a worksheet formula in "Cell B" (which presumably refers to Cell A), which would allow SpreadsheetGear to handle the calculation for you? – Tim Andersen Feb 15 '17 at 21:35

0 Answers0