Selectionchanged & combo celltype

Posted by: kingmanb on 8 September 2017, 3:23 pm EST

    • Post Options:
    • Link

    Posted 8 September 2017, 3:23 pm EST

    Hi folks,

    the selectionchanged event does not fire when a user clicks on a combobox cell type. It does fire when a user moves to the cell by arrow key.

  • Posted 8 September 2017, 3:23 pm EST

    Hi,

    ComboBoxCellType is one of the cell types that has “reserved locations” (for buttons) that can activate edit mode on mouse down, so when the user clicks the left mouse button down inside the drop-down button for the combo box in the cell, then the cell immediately enters edit mode and the combo box shows the list, instead of starting selection mode to select a range of cells on the left mouse button down. If the combo box in the cell is set up to show a drop-down list (and not allow editing of the text box) then the entire cell rectangle is a reserved location that behaves that way. When the cell enters edit mode, the active cell changes first (LeaveCell event) and then EditModeStarting, but selection has been skipped completely. If you need event notification when the user clicks in the combo box cell type, then those events might work instead of SelectionChanged (which is intended to notify when the selected range in the sheet has changed).

    When you navigate using the arrow keys, SelectionChanged always fires because that action always changes the selection in the sheet (since there is no similar processing for invoking edit mode automatically, as in the case of the left mouse button down above). If the Shift key is also down, then the selection is extended in the direction of the arrow key and the active cell moves (if possible); if the shift key is not down, then the active cell moves in the direction of the arrow key and the active cell moves (if possible).

    There is a property, AllowEditorReservedLocations, which can disable all processing of the reserved locations inside the cell types:

    http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~AllowEditorReservedLocations.html

    If you set that property to false, then cells containing combo boxes, buttons, check boxes, sliders, etc. will not enter edit mode when their reserved locations are clicked, and those locations will no longer show mouse cursors when the mouse moves over to indicate that editing can be initiated on left mouse button down. Those cells can be selected like other cells that don’t have reserved locations, and the user must double-click the cell to enter edit mode to edit the value in the combo box, check box, slider, etc. or to click the button in a button cell.

    Regards,

    -Sean

  • Posted 8 September 2017, 3:23 pm EST

    Thanks Sean for your quick & extensive reply!

    I’d hate to lose all the functionality by disabling the AllowEditorReservedLocations. My q&d solution:

    Private Sub FpSpread1_EnterCell(sender As Object, e As EnterCellEventArgs) Handles FpSpread1.EnterCell

    If FpSpread1.ActiveSheet.ActiveColumn.CellType IsNot Nothing Then

    If FpSpread1.ActiveSheet.ActiveColumn.CellType.GetType = GetType(CellType.ComboBoxCellType) Then

    selectionChanged(FpSpread1, e.Row, 1, e.Column, 1) <– the sub that handles the FpSpread1_SelectionChanged event

    End If

    End If

    End Sub

    -Kingman

  • Posted 8 September 2017, 3:23 pm EST

    Hello Kingman,

    We are glad to know that your issue has been resolved.

    Thanks,

    Reeva

  • Posted 27 February 2018, 12:53 am EST

    Thank Sean!!!

    I failed to try for solving this issue long time ago, but it’s really lucky when I come back again on this and find your solution.

    Thanks again!!!

    Vinh

Need extra support?

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

Learn More

Forum Channels