This project is read-only.

Detect "multi-change" (like paste of a range)

Jul 7, 2009 at 4:41 PM


I'm adding an History function to my grid (undo/redo). It works fine for value edition and row insertion or deletion, but I'm trying to manage undo/redo groups. I mean, for example, detect a modification on many cells that has been done in one "click", eg on a copy/paste.

Now I'm working with the "OnValueChanged" of Cell element.

Is there something like "OnRangeChanged" or do anybody have an idea on how do know if several cells have been modified at the same time (without working with a timer) ?

I'll try to check if I can work with the active selection, but I think it can have some unwanted effects.

Thanks for your ideas/help.

Jul 8, 2009 at 7:40 AM

An idea:

Somewhere a list of changed cells is kept, and when the user tells that an editing operation is finished, then that list is sent with a "OnRangeChanged" event.  this could be as a simple class in your project, and if it will work nice and clean, it might be included in SourceGrid at some time.

Jul 9, 2009 at 4:15 PM
Edited Jul 10, 2009 at 2:26 PM

Thanks, yes, it's an idea. The problem is that the the user has to say "I've finished". In the case of "Paste from clipboard", I think that only SourceGrid knows when it's finished.

I can "play" with a timer or try something when ActiveCell or Selection changes (often the case when copy/paste, but not always), but perhaps an event (RangeChanged or AfterClipboardPaste or ...) would be useful.


I made it with KeyDown event (catching "Del", "Ctrl+C", ...) in addition with "sender.Grid.Selection.GetSelectionRegion().GetCellsPositions()" to know own many Cells are affected.
I think it's not a too bad way :)