Custom Hyperlink CellType in Spread for Win 4.0.3510.2008

Posted by: lmlascola on 8 September 2017, 1:54 pm EST

  • Posted 8 September 2017, 1:54 pm EST

    We are currently using Spread 4.0.3508.2008, and are evaluating upgrading to 4.0.3510.2008.  We have a problem with bug 22890 (LargeChange exception) which has been corrected in version 4.0.3509.2008.  However, we implemented a custom hyperlink cell type, which allows us to display a databound hyperlink rather than a hard-coded URL.  We retrieved the code sample from this forum, and it has been working quite nicely for a while with version 4.0.3508.2008.  However, in version 4.0.3510.2008, the value parameter that is passed in to the PaintCell override is always null.  How do we make a custom hyperlink work in version 4.0.3510.2008?


        public class DataGridHyperLinkCellType : FarPoint.Win.Spread.CellType.HyperLinkCellType
        {


            public DataGridHyperLinkCellType()
                : base()
            {
            }


            ///


            /// HyperLinkCellType uses the Text property to display value in the grid
            ///

            public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
            {


               // value is always null in version 4.0.3510.2008
                this.Link = value == null ? "" : value.ToString();
                base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
            }


            ///


            /// Prevent editing of the hyperlink cell
            ///

            public override void StartEditing(EventArgs e, bool selectAll, bool autoClipboard)
            {
                CancelEditing();
            }


            public override object GetEditorValue()
            {
                return base.Link;
            }
        }


     

  • Replied 8 September 2017, 1:54 pm EST

     


    Hello,


    I have reported this issue to our QA team as a bug, Bug Number: 25836. Hope this will be fixed in next maintenance release of Spread for Windows.


     


    Thanks, 

  • Replied 8 September 2017, 1:54 pm EST

    We really need to upgrade to fix the LargeChange exception problem.  There is a workaround, but unfortunately this does not look good (the spread scrolls when we don't want it to). http://www.clubfarpoint.com/Forums/forums/2/68507/ShowThread.aspx


    Is there a work around for bug 25836 that you just reported?  Is there some other way we can do a bound hyperlink cell?

  • Replied 8 September 2017, 1:54 pm EST

    Hi, 

    As a work around, you may use the FpSpread1_ButtonClicked event of the spread. This event gets called whenever you click a HyperlinkCellType or ButtonCellType. In this event you may set the link to open using: 

    CType(e.EditingControl, FarPoint.Win.FpHyperlink).Link="Http://Google.com"

    Regards, 

  • Replied 8 September 2017, 1:54 pm EST

    If you can set the celltype on the Column you could get around the problem. The bug is in the set of the CellType property of the Cells object.
  • Replied 8 September 2017, 1:54 pm EST

    Hello,


    Regarding the bug # 25836, that was posted earlier it has been observed as an Intended behavior by the concerned teamThe value stored in the data model for the Hyperlink celltype is not the link but an array of boolean values (one for each link in the cell) that specifies whether the link has been visited or not. Passing a Text value down into the base class PaintCell is probably causing an exception that is being caught. I made some changes in your code the "value" is not getting null now.


    public class DataGridHyperLinkCellType : FarPoint.Win.Spread.CellType.HyperLinkCellType


    {


    public DataGridHyperLinkCellType()


    : base()


    {


    }


    ///


    /// HyperLinkCellType uses the Text property to display value in the grid


    ///


    public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)


    {


    //this.Link = value == null ? "" : value.ToString();


    Link = value.ToString();


    base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);


    }


    ///


    /// Prevent editing of the hyperlink cell


    ///


    //public override void StartEditing(EventArgs e, bool selectAll, bool autoClipboard)


    //{


    // CancelEditing();


    //}


    public override object GetEditorValue()


    {


    return base.Link;


    }


    }


    Hope It will Help you.


    Thanks,

Need extra support?

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

Learn More

Forum Channels