Right click operation

Posted by: sidso on 8 September 2017, 1:05 pm EST

  • Posted 8 September 2017, 1:05 pm EST

    Hi ,


    I am doing a right click on the active sheet to get a specific context menu. The same should not happen when i click on the empty space inside the grid. For example if i have a sheet with only one row and later has empty grey space. When i right click on the grey space the spread cellclick event is not getting fired and it is showing me the same context menu strip. Can u tell me which even gets fired when i click on the grey area or how to stop the displaying of the context menu.


     


    Thanks


    Regards


    Sid

  • Replied 8 September 2017, 1:05 pm EST

    Sid -

    About the only way of doing this is in the MouseDown event and check for the Row and Column returning -1.  If they do you know you are outside of the cell area of the sheet...

    Private Sub FpSpread1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FpSpread1.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Right Then
    Dim range As FarPoint.Win.Spread.Model.CellRange = FpSpread1.GetCellFromPixel(0, 0, e.X, e.Y)
    If range.Row = -1 And range.Column = -1 Then
    'your code here to turn off ContextMenu
    End If
    End If
  • Replied 8 September 2017, 1:05 pm EST

    Hi bob,


    Thank you so much. Its working fine now. Hey....was looking at the forum pics.... how about sending us a few T-Shirts... would love to have one.... :-)


    Regards


    sid

  • Replied 8 September 2017, 1:05 pm EST

    Hey...,


    I am facing another issue now. for fixed columns by default the row number and column number is giving me -1 and -1, and the above condition is failing because of this....


    Regards


    sid

  • Replied 8 September 2017, 1:05 pm EST

    sid -

    I am not sure what you mean by 'fixed columns'.  Could you elaborate.
  • Replied 8 September 2017, 1:05 pm EST

    By fixed column I mean to say frozen column in the grid which doesn't move when scrolling.


    Right click on the cells in the frozen column range it gives column and row as -1. Please help me in fixing this.


    sid

  • Replied 8 September 2017, 1:05 pm EST

    sid -

    Frozen columns reside in a different viewport.  You are going to have to re-work your code by checking if the columns are frozen and use a different viewport in your check...

    FpSpread1.GetCellFromPixel(0, -1, e.X, e.Y)
  • Replied 8 September 2017, 1:05 pm EST

    sid -

    I believe this code will do what you are looking for...

    Private Sub FpSpread1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FpSpread1.MouseDown
    Dim i As Integer = FpSpread1.GetRootWorkbook.GetColumnViewportIndexFromX(e.X)
    Dim range As FarPoint.Win.Spread.Model.CellRange
    If i = -1 Then
    range = FpSpread1.GetCellFromPixel(0, -1, e.X, e.Y)
    If range.Row = -1 And range.Column = -1 Then
    MsgBox(range.Row)
    End If
    ElseIf i = 0 Then
    range = FpSpread1.GetCellFromPixel(0, 0, e.X, e.Y)
    If range.Row = -1 And range.Column = -1 Then
    MsgBox(range.Row)
    End If
    End If
    End Sub
Need extra support?

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

Learn More

Forum Channels