Right click context menu on editable cell?

Posted by: sneha on 8 September 2017, 1:51 pm EST

  • Posted 8 September 2017, 1:51 pm EST

    Is possible to create a right click context menu on a cell which is in editable mode?
  • Replied 8 September 2017, 1:51 pm EST

    Hi Suresh,


    Thanks for the suggestion but through this its not showing context menu for that perticular cell. Through ActiveColumnIndex we can recognize perticular colum but how it will recognize that we have performed right click on perticular cell of that column?


     


     

  • Replied 8 September 2017, 1:51 pm EST

    Hello Sneha,

    In case you wish to have your own context menu, when you right click on a cell which is in edit mode, then you may use the EditModeOn event along with the ContextMenuStrip to get the desired behavior. I have tested the below snippet with 4.0.2009.2005 build of Spread in VS2005.

     Private Sub FpSpread1_EditModeOn(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.EditModeOn

            Dim t As FarPoint.Win.Spread.CellType.GeneralEditor
            Dim cms As New Windows.Forms.ContextMenuStrip
            cms.Items.Add("test1")
            cms.Items.Add("test2")
            cms.Items.Add("test3")
            cms.Items.Add("test4")
            t = CType(FpSpread1.EditingControl, FarPoint.Win.Spread.CellType.GeneralEditor)
            FpSpread1.EditingControl.ContextMenuStrip = cms

    End Sub 

    Hope this helps. Thanks

  • Replied 8 September 2017, 1:51 pm EST

    Hello,


    You can either use the CellClick event and check the cell that was right clicked. Or you can use the GetCellFromPixel method to determine the cell the mouse is over at a particular time.

  • Replied 8 September 2017, 1:51 pm EST

    Hi Scotts,


    CellClick event is not getting fired when the cell is in edit mode. Actually i din't find any event which is getting fired when the cell is in edit mode.


    And can you please give detail information or code about GetCellFromPixel method.

  • Replied 8 September 2017, 1:51 pm EST

    Hello,


    I did not realize you were in editmode. You are correct that this event will not fire. Why would you not just check the ActiveRowIndex and ActiveColumnIndex properties to determine the cell? The GetCellFromPixel method uses the x and y coordinate, you can get from the mouse and will return the cell that is located at that point.

  • Replied 8 September 2017, 1:51 pm EST

    Thanks scotts for your suggestion.


    I got the resolution for this to dispaly our own contex menu when the cell is in the editable mode. For this we need to use EditModeOn event along with contextMenu.


    Private Sub FpSpread1_EditModeOn(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.EditModeOn
            Dim cms1 As New Windows.Forms.ContextMenu
                cms1.MenuItems.Add("&Item1", New EventHandler(AddressOf Me.Menu_Click))
                cms1.MenuItems.Add("&Item2")
                FpSpread1.EditingControl.ContextMenu = cms1
    End Sub


    Suresh,
    This i am not able to achive it through ContextMenuStrip.

Need extra support?

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

Learn More

Forum Channels