How to change the backcolor when override PaintCell

Posted by: kukemaster on 8 September 2017, 3:02 pm EST

  • Posted 8 September 2017, 3:02 pm EST

    I create a custom celltype, nad override the PaintCell, but the backcolor of cell change to Colors.Control, How to change the Colors.Control to Colors.Wilte

     

            public override void PaintCell(Graphics g, Rectangle r,
    FarPoint.Win.Spread.Appearance appearance, object value, bool
    isSelected, bool isLocked, float zoomFactor)
            {
                if (value != null)
                {
                    Image img = value as Image;
                    g.DrawImage(img, new Rectangle(new Point(r.X, r.Y), new Size(200, 200)));
                    g.DrawString(strValue, appearance.Font, new SolidBrush(Color.Black), new PointF(r.X, r.Y + 200));
                }
                else
                {
                    base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
                }
            }

  • Replied 8 September 2017, 3:02 pm EST

    Hello,

    You can reset the BackColor of a custom celltype while overriding the PaintCell method by using the appearence parameter passed to this method. Here is a code snippet implementing the same:

     public override void PaintCell(Graphics g, Rectangle r,
    FarPoint.Win.Spread.Appearance appearance, object value, bool
    isSelected, bool isLocked, float zoomFactor)
            {
             
                    appearence.BackColor = Color.Red;
                    base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
               
            }

    Hope it will help you. Please let me know if yo have any queries further.

    Thanks,

    Manpreet Kaur

Need extra support?

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

Learn More

Forum Channels