how can i get last edit cell position?

2 posts, 0 answers
  1. jun
    jun avatar
    1 posts
    Member since:
    May 2015

    Posted 05 Aug 2015 Link to this post

    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 ?   

  2. Anna
    Admin
    Anna avatar
    99 posts

    Posted 06 Aug 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top