Home Forums WinForms controls Xceed Grid for WinForms Forecolor only for a part of a cell Reply To: Forecolor only for a part of a cell

User (Old forums)
Member
Post count: 23064

To do this, you can create a class that implements the <b>Xceed.Grid.ICellViewer</b> interface, and set the <b>CellViewer</b> property of the column(s) to an instance of this class. In your class, you should write code that paints the content of the cell like you want. This is how it should look (untested code):<code>using Xceed.Grid;
public class MyCellViewer : ICellViewer
{
public int GetFittedWidth(Cell cell) { return -1; }
public int GetFittedHeight(Cell cell, AutoHeightMode mode) { return -1; }
public bool PaintCellValue(GridPaintEventArgs e, Cell cell) {
// here you put your paint code.
// here are some objects you might need:
// string text = cell.GetTextToPaint(); // the text of the cell
// Graphics g = e.Graphics; // the Graphics object to paint on
// Rectangle rect = e.DisplayRectangle; // the display rectangle of the cell
}
}</code>

Imported from legacy forums. Posted by Tommy (had 200 views)