Cell alignment ignored when using ICellType

Posted by: c12008 on 8 September 2017, 3:16 pm EST

  • Posted 8 September 2017, 3:16 pm EST

    Hi Guys,

    I´m using a custom cell type implementing the ICellType interface - not derived from farpoint standard cell types.
    I´ve set cell alignment for my spread sheet (vertical / horizontal).
    All cells using standard celltypes are aligned correctely.
    All cells using my custom cell type ignore the alignment setting.
    The content of these cells are always aligned with the default alignment settings.

    Does anyone has an idea to solve that?

    Regards
    c12008
  • Replied 8 September 2017, 3:16 pm EST

    Hello C12008,

    When creating a custom Celltype that are not derived from Standard CellType, the alignment of cells with that custom CellType will be the alignment of control from which they are created. For example, if you are creating a user control and the alignment of that user control is 'Center' then the alignment of the cells that have the CellType created from that user control will be 'Center' and hence setting cell alignment wont affect them.

    Hope it clarifies.

    Thanks,
    Ankita
  • Replied 8 September 2017, 3:16 pm EST

    Hi Ankita,

    Ok, I understand.
    But what do I have to do to make my custom celltype "use" the spread alignment settings like the standard cell types.
    My celltype is not derived from any other celltype and also not derived from another user control.

    Regards,
    c12008
  • Replied 8 September 2017, 3:16 pm EST

    Hello,


    We are sorry to mention but it is not possible to achieve your requirement directly with the custom CellType. However, you may use the given workaround for achieving your requirements. First check the alignment of the cell and then, draw any control/string in the cell according to its alignment. To do the same, you may use the following code:

    public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appr, object value, bool issel, bool
    islocked, float zoom)
    {
    if (appr.HorizontalAlignment.ToString() == "Right")
    {
    //Paint the control according to the alignment
    }

    else if(appr.HorizontalAlignment.ToString() == "Left")

    {

    //

    //Paint the control according to the alignment set

    }

    .......

    .....

    }


    You may use the same process with 'VerticleAlignment' as well.

    Thanks & Regards,
    Pragati Kaushik
  • Marked as Answer

    Replied 8 September 2017, 3:16 pm EST

    Hi,

    Thank you.
    That solved my issue.

    Best regards
    c12008
Need extra support?

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

Learn More

Forum Channels