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

    <p>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</p><p> </p><p>        public override void PaintCell(Graphics g, Rectangle r,
    FarPoint.Win.Spread.Appearance appearance, object value, bool
    isSelected, bool isLocked, float zoomFactor)<br>        {<br>            if (value != null)<br>            {<br>                Image img = value as Image;<br>                g.DrawImage(img, new Rectangle(new Point(r.X, r.Y), new Size(200, 200)));<br>                g.DrawString(strValue, appearance.Font, new SolidBrush(Color.Black), new PointF(r.X, r.Y + 200));<br>            }<br>            else<br>            {<br>                base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);<br>            }<br>        }</p>
  • Replied 8 September 2017, 3:02 pm EST

    <p>Hello,</p><p>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:</p><p> public override void PaintCell(Graphics g, Rectangle r,
    FarPoint.Win.Spread.Appearance appearance, object value, bool
    isSelected, bool isLocked, float zoomFactor)<br>        {<br>          <br>                appearence.BackColor = Color.Red;<br>                base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);<br>            <br>        }</p><p>Hope it will help you. Please let me know if yo have any queries further.</p><p>Thanks,</p><p>Manpreet Kaur <br></p>
Need extra support?

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

Learn More

Forum Channels