LinkClicked event for RichTextCellType containing hyperlink

Posted by: mikes on 25 July 2022, 3:07 pm EST

    • Post Options:
    • Link

    Posted 25 July 2022, 3:07 pm EST

    Is it possible to be able to handle an event for when the user clicks on a hyperlink inside a rich text cell type?

    I can see when I go into edit mode that the icon changes to the hand icon when over a hyperlink, and I can see the RichTextEditor control has a LinkClicked event - but I can’t work out how I can get that event.

    If I have a Farpoint Spread control named grdNotes, I can set a cells CellType to be RichTextCellType and the user can enter rich text:

    FarPoint.Win.Spread.CellType.RichTextCellType rtfCellType = new FarPoint.Win.Spread.CellType.RichTextCellType();
                grdNotes.ActiveSheet.Cells[0, 0].CellType = rtfCellType;
    

    But how do I get the RichTextEditor from that cell? RichTextEditor exists in the FarPoint.Win.Spread.CellType namespace, and it has a LinkClicked event which seems to be what I want, but I can’t get that control.

  • Posted 25 July 2022, 6:16 pm EST

    Hi,

    You can handle the EditModeOn event and then use the EditingControl property of the FpSpread to get the RichTextEditor being used to edit the cell. Then you can handle its LinkClicked event. Please refer to the code below:

    private void FpSpread1_EditModeOn(object sender, EventArgs e)
            {
                    var editor = fpSpread1.EditingControl as FarPoint.Win.Spread.CellType.RichTextEditor;
                    if (editor != null)
                        editor.LinkClicked += Editor_LinkClicked;
                
            }
    

    Regards

    Avnish

  • Posted 26 July 2022, 1:54 pm EST - Updated 30 September 2022, 4:05 am EST

    Thanks - that worked, but I needed expand your answer to also remove the handler in a handler for EditModeOff - otherwise I got the LinkClicked event multiple times.

Need extra support?

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

Learn More

Forum Channels