Selection is lost when I select multple cells and invoke context menu

  • v_venkie 3 years, 9 months ago

    Hi,

     I use Farpoint Spread for Windows Forms v5. I have a requirement to allow a user to select multiple cells and if the user clicks on one of the selected cells, a context menu needs to appear. However, in my case, the moment i click on one of the selected cells, the selection is lost.

     I have the following properties on the spread.

    spread.SelectionBlockOptions = SelectionBlockOptions.Cells | SelectionBlockOptions.Columns;
    spread.ActiveSheet.SelectionPolicy = SelectionPolicy.MultiRange;
     

    I also handle the Cell Click event which performs some actions on my model.

    I tried setting RetainSelectionBlock property to true but it doesnt help. I read in the help file that

    The RetainSelectionBlock property applies to cell selections in the grid modes (Normal and ReadOnly) and also applies to cell focus indicators (Normal and RowMode). This property does not apply to row selections in the list modes (RowMode, SingleSelect, MultiSelect, ExtendedSelect). List boxes always show their row selections.
    The RetainSelectionBlock property does not apply to row selections in the the list modes (RowMode, SingleSelect, MultiSelect, ExtendedSelect).

    Mine is a multi select but a cell selection not row selection. Does this restriction apply even then?

    Could you please advise.

     Thanks!

    Regards

    Venkatesh V.

  • 1p
    paul19601p 3 years, 9 months ago

    Yes if you use multiselect operationmode then the RetainSelectionBlock Property is not used, however you can catch the FpSpread.SelectionChanging Event and change the cancel property of its SelectionChangingEventArgs to = true to cancel the selection change event, you will just need to figure out the conditions under which you want to do that. Here is code I found that canceled the selection change if you clicked on column zero.

    C# Copy Code
    private void fpSpread1SelectionChanging(object sender, FarPoint.Win.Spread.SelectionChangingEventArgs e)
    {
       
    if (e.CurrentColumn == 0)
       {
           e.Cancel = true;
       }
    }
    Visual Basic Copy Code
    Private Sub FpSpread1SelectionChanging(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SelectionChangingEventArgs)
    Handles FpSpread1.SelectionChanging
        If e.CurrentColumn = 0 Then
            e.Cancel = True
        End If
    End Sub
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.