Row Selection Via Mouse Drag

Posted by: griswald88 on 8 September 2017, 12:36 pm EST

  • Posted 8 September 2017, 12:36 pm EST

    What properties would prevent me from clicking and dragging on a row header to select multiple rows? Currently I cannot do this unless I use the SHIFT and Arrow Keys, but I know it's possible and that I may have set a property that prevents this.


    Thanks!

  • Replied 8 September 2017, 12:36 pm EST

    SelectionStyle=SelectionRenderer
  • Replied 8 September 2017, 12:36 pm EST

    Yeah I had looked at those, but they looked fine to me.


    SelectionPolicy=Range


    SelectionUnit=Cell


    OperationMode=Normal

  • Replied 8 September 2017, 12:36 pm EST

    It is most likely either the SelectionPolicy, the SelectionUnit or the OperationMode.
  • Replied 8 September 2017, 12:36 pm EST

    Ok here is the issue, I have row headers that span multiple rows and in the CellClick I have the following code:


    'if dealing with a row header


    If e.RowHeader Then


    'cancel the normal selection


    e.Cancel = True


    'select all the rules's corresponding rows


    grdCriteria.ActiveSheet.Models.Selection.SetSelection(e.Row, -1, grdCriteria.ActiveSheet.RowHeader.Cells(e.Row, e.Column).RowSpan, -1)


    End If 'if dealing with a row header condition


    This works fine for selecting the rows that are spanned by the header, but because of the cancel = true, the mouse dragging is prevented. Is there another way to accomplish this?

  • Replied 8 September 2017, 12:36 pm EST

    I can't think of anything else that would prevent you from selecting the rows.  Can you attach a small project that shows the issue for us to look at?
  • Replied 8 September 2017, 12:36 pm EST

    What about the SelectionStyle?
  • Replied 8 September 2017, 12:36 pm EST

    Are you setting the AllowColumnMove/AllowRowMove property (is that how you want the user to drag)?
  • Replied 8 September 2017, 12:36 pm EST

    griswald88 -

    You shouldn't need another column in your row header.  Just check to see if you are clicking in a span and if so cancel the event, otherwise you can select rows by dragging like you normally would...

    Private Sub FpSpread1_CellClick(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick
    Dim cr As FarPoint.Win.Spread.Model.CellRange

    If e.RowHeader Then
    cr = CType(FpSpread1.ActiveSheet.Models.RowHeaderSpan, FarPoint.Win.Spread.Model.DefaultSheetSpanModel).Find(e.Row, e.Column)
    If Not cr Is Nothing Then
    FpSpread1.ActiveSheet.Models.Selection.SetSelection(cr.Row, -1, cr.RowCount, 1)
    e.Cancel = True
    End If
    End If
    End Sub
  • Replied 8 September 2017, 12:36 pm EST

    So if you have a row header span over two rows (FpSpread1.Sheets(0).AddRowHeaderSpanCell(0, 0, 2, 1)) and the user only selects the row header (so only the first row is selected, not both rows that are part of the span), you want to use code to select both rows that are part of the span.  As long as the user keeps dragging then both would be selected.  However if they stop at the first row then only the one row and the header are selected.

    There is a selectionchanged event that fires after the selection.  This will not prevent you from dragging but, you have to select everything again in code.

    You could create a custom combo cell.
  • Replied 8 September 2017, 12:36 pm EST

    What exactly are you trying to do?  Perhaps there are other events that you could use.
  • Replied 8 September 2017, 12:36 pm EST

    No, I have those properties set to false because I want the user to be able to click in a row header and drag down, selecting the rows as it traverses. This works perfectly until I handle the custom row span selection in the CellClick and set the e.Cancel property to True. I have worked around this issue by inserting an additional row header column used for single row selection, but it would still be nice how to handle this issue for the future.


    Also, is it possible to distinguish between combobox (cell type) items via fonts, colors, lines, or anything along those lines?

  • Replied 8 September 2017, 12:36 pm EST

    When I click a row header, I want to automatically select all the rows in the row header's row span.

Need extra support?

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

Learn More

Forum Channels