Detecting Cell Deselection

Posted by: cdanila on 9 July 2026, 8:05 am EST

    • Post Options:
    • Link

    Posted 9 July 2026, 8:05 am EST

    I am evaluating FarPoint Spread for .Net WinForms and I am using the SelectionChanged event to track selection changes and need clarification on how to properly detect when a cell has been deselected.

    Scenario 1:

    I select an entire row (all columns in that row). While holding Ctrl, I click a single cell in the middle of that row to deselect it. The SelectionChanged event fires with e.Range values, but I cannot determine that a deselection occurred.

    Scenario 2:

    I select a rectangle of 9 cells (3x3 grid). While holding Ctrl, I click the center cell to deselect it. The SelectionChanged event fires, but the returned e.Range values do not seem to correspond to the actual column position of the deselected cell. The range appears to span multiple columns that don’t match the deselection action.

    Question:

    How should I use the SelectionChanged event and its Range property to reliably detect that a cell was deselected? The e.Range values don’t seem to accurately represent the deselection action in either scenario.

    Should I somehow compare with GetSelections() before and after to detect deselections, or is there a proper way to interpret e.Range for this purpose?

    Any documentation or code examples would be appreciated.

    Thank you!

  • Posted 10 July 2026, 3:01 am EST

    Hi Claudiu,

    Thank you for reaching out.

    We investigated the behavior of the SelectionChanged event and found that the SelectionChangedEventArgs.Range property is intended to indicate the range associated with the selection change. However, it does not explicitly indicate whether cells were selected or deselected, nor does it provide the previous selection state. Therefore, it cannot be used by itself to reliably determine which cells were deselected in scenarios such as Ctrl+Click deselection.

    As a workaround, you can compare the current selection obtained through SheetView.GetSelections() with the previously stored selection state. By maintaining the previous selection and comparing it with the current one inside the SelectionChanged event, you can accurately identify both newly selected and deselected cells. We have attached a sample application that demonstrates this approach.

    Additionally, we have escalated this matter to the concerned development team under the internal tracking ID SPNET-54820. We will keep you informed as soon as we receive an update from them.

    Please let us know if you require any further assistance.

    Kind Regards,

    Chirag

    Attachment: DeselectCell.zip

  • Posted 10 July 2026, 3:33 am EST

    Hi Claudiu,

    Thanks for your patience while we discussed this matter with the concerned team.

    As per their inputs, you can use the SelectionChanging event along with the SelectionChanged event to detect cell deselections using the following code:

    fpSpread1.SelectionChanging += FpSpread1_SelectionChanging;
    fpSpread1.SelectionChanged += FpSpread1_SelectionChanged;
    CellRange lastSelectingRange;
    private void FpSpread1_SelectionChanging(object sender, SelectionChangingEventArgs e)
    {
        lastSelectingRange = e.Range;
    }
    private void FpSpread1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var sheetView = e.View.GetSheetView();
        if (!sheetView.IsSelected(lastSelectingRange.Row, lastSelectingRange.Column))
        {
            Debug.WriteLine("Deselected: " + lastSelectingRange.ToString());
        }
    }

    You can further refer to the attached code sample that demonstrates the usage of the above code snippet (see below).

    Please let us know if you encounter any further issues or require additional assistance.

    Kind Regards,

    Chirag

    Attachments: DeselectCell.zip

  • Posted 13 July 2026, 5:36 am EST - Updated 13 July 2026, 5:36 am EST

    So the purposed workaround relies on previous chnging event, indeed it is what I am looking for, the event is not triggered in all cases like columns selections but I extended it a bit and it works.

    Thank you.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels