This is a migrated thread and some comments may be shown as answers.

how can i get last edit cell position?

1 Answer 103 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
jun
Top achievements
Rank 1
jun asked on 06 Aug 2015, 02:43 AM

sorry, I can't speak English.

I have question.

 

row 1, column 1 cell   typing   "AAA"

row2, column1 cell  "keyboard down" or "mouse click"

focus changed. 

 

how can i get last edit cell position?    last edited  "row 1, column 1",  value = "AAA"

 

use WorkbookConentChanged ?   

1 Answer, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 06 Aug 2015, 11:28 AM
Hi,

You are right that the WorkbookContentChanged event would notify you for each edit. However, this event does not give information about which range was modified. I would suggest using the CellPropertyChanged event instead as its event arguments provide this information. You can find the event in the Cell property of each worksheet and the handler would look like this:

private void Cells_CellPropertyChanged(object sender, CellPropertyChangedEventArgs e)
{
    if (e.Property == CellPropertyDefinitions.ValueProperty)
    {
        CellRange range = e.CellRange;
    }
}


If your workbook has more than one worksheet, you can subscribe to the ActiveSheetChanged event of the RadSpreadsheet. This way each time the active worksheet is changed, you will make sure that you are subscribed to its CellPropertyChanged event.

public MainControl()
 {       
     this.radSpreadsheet.Workbook.ActiveWorksheet.Cells.CellPropertyChanged += Cells_CellPropertyChanged;
     this.radSpreadsheet.ActiveSheetChanged += radSpreadsheet_ActiveSheetChanged;
 }
 
 void radSpreadsheet_ActiveSheetChanged(object sender, EventArgs e)
 {
     this.radSpreadsheet.ActiveWorksheet.Cells.CellPropertyChanged -= Cells_CellPropertyChanged;
     this.radSpreadsheet.ActiveWorksheet.Cells.CellPropertyChanged += Cells_CellPropertyChanged;
 }


The event will not fire when the focus is changed, so you will get the last edit position, as you described.

I hope this helps. Please, let us know if you have any questions.

Regards,
Anna
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Spreadsheet
Asked by
jun
Top achievements
Rank 1
Answers by
Anna
Telerik team
Share this question
or