Pad cell data so the error icon does not overlap?

  • imgodot 2 months, 1 week ago

    Is there a way to give a Spread cell a margin or padding so that the error icon does not overlap the data in the cell?

    Thanks.
    – Paul

  • 50p
    Deepak Sharma50p 2 months, 1 week ago

    Hi,

    You can create an object of CellPadding class and assign it to the cell/row/column to set the cell padding. Here you can set the padding for top, bottom, left right and all. For example:

    FarPoint.Win.Spread.CellPadding test = new FarPoint.Win.Spread.CellPadding();
                test.All = 2;         
                fpSpread1.ActiveSheet.Columns[1].CellPadding = test;
                fpSpread1.ActiveSheet.Cells[0, 1].Text = “test”;
                fpSpread1.ActiveSheet.Cells[0, 0].Text = “test”;

    Regards,
    Deepak Sharma

  • imgodot 2 months, 1 week ago

    Deepak,

    Thanks for the reply but CellPadding does not really do what I need.
    However, I did find that I can alter the “TextIndent” property to prevent the error icon from overlapping the cell data, in most cases.

    Different/related question:
    I know there is a way to make the error icon be displayed near the left edge of a cell by overriding GetErrorIconBound but what would a class look like to do that? I presume it needs to be done by creating an “alternate”/inherited cell type, though I don’t know, and I’ve never done it.

    Also, if it is done by creating an “alternate”/replacement cell type, would I have to create an “alternate” cell type for a text cell type and a date cell type, etc?

  • 50p
    Deepak Sharma50p 2 months, 1 week ago

    Hello,

    You can create a custom class for error icon implementing ‘IErrorIconRenderer’ and assign the class object to SpreadView. Something like this:

    public class CustomError : IErrorIconRenderer
        {         
            public void Dispose()
            {           
                //throw new NotImplementedException();
            }
    
            public void Paint(Graphics g, Rectangle rectPaint)
            {
              //your code here
            }
        }
    
     FarPoint.Win.Spread.SpreadView sv = fpSpread1.GetRootWorkbook();
     sv.ErrorIconRenderer = new CustomError();

    Please let me know in case you face any issues , implementing the same.

    Regards,
    Deepak Sharma

  • imgodot 2 months, 1 week ago

    Deepak,

    Thanks for the snippet, but only now did I find someone who asked the same question on the forum; and that raises a question.

    In the other forum post (http://sphelp.grapecity.com/forums/topic/change-the-error-icon-position-when-cell-is-numbercelltype/), Sean Lawyer suggested overriding the error icon renderer.

    However, that did not affect where the “hotspot” was for the error text popup.
    Due to that issue, Sean replied with this,

    It does not appear to be possible to customize the location where the cell error popup is shown on hover over the error indicator.
     The point where the popup is shown is calculated from the rectangle for the cell error indicator, which is returned from the cell type’s implementation for GetErrorIconBound.
    
    If you want to customize the position of the error icon and error popup for a particular cell type, then overriding GetErrorIconBound is the way to do it.

    I presume I would want to do the same thing.
    How would I go about overriding “GetErrorIconBound”?
    If I do that, do I have to do it for each celltype?

    Thanks.
    – Paul

  • 50p
    Deepak Sharma50p 2 months, 1 week ago

    Hi Paul,

    I think you would need to do it for each celltype.
    I am working on the sample application for you I will get back to you soon.

    Regards,
    Deepak Sharma

  • 50p
    Deepak Sharma50p 1 month, 4 weeks ago

    Hi Paul,

    Developers suggested that setting the TextIndent is the best possible solution for this issue.

    Thanks,
    Deepak Sharma

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to create new topics.