Home Forums WinForms controls Xceed Grid for WinForms Cell Backcolor

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13856 |

    Hi,

    Does anyone know if it’s possible to paint just one part of a cells backcolor?

    Imported from legacy forums. Posted by Jeff_ (had 2719 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t really understand what you mean by ‘painting just one part’. Could you explain some more?

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

    User (Old forums)
    Member
    Post count: 23064

    Hi Tommy,

    I try to explain it better.

    In the grid we have the possibility to set the backcolor of the cells, but when you set the backcolor of a cell the cell is completly painted in that color.

    What I want to know is if it’s possible to split a cell in two ore more parts and to set a different color for each part.

    Here is an example of a cell I need.
    http://www.bitmap.lu/grid.jpg

    Sorry for my bad english.

    Imported from legacy forums. Posted by Jeff_ (had 409 views)

    User (Old forums)
    Member
    Post count: 23064

    You can do it, like this (the code below has not been tested):
    1. Create a class that inherits from <b>Xceed.Grid.DataCell</b>:<code>public class MyDataCell : Xceed.Grid.DataCell
    {
    public MyDataCell() { }
    public MyDataCell(string fieldName):base(fieldName) { }
    public MyDataCell(MyDataCell template):base(template) { }
    public MyDataCell(Column column):base(column) { }
    protected override Cell CreateInstance() {
    return new MyDataCell(this);
    }
    <b>protected override void PaintBackground(GridPaintEventArgs e) {
    // here you put code to paint the background of the cell
    }</b>
    }</code>2. Create a class that inherits from <b>Xceed.Grid.DataRow</b>:<code>public class MyDataRow : Xceed.Grid.DataRow
    {
    public MyDataRow() { }
    public MyDataRow(MyDataRow template):base(template) { }
    public MyDataRow(RowSelector selector):base(selector) { }
    protected override Row CreateInstance() {
    return new MyDataRow(this);
    }
    protected override Cell CreateCell(Column column) {
    return new MyDataCell(column);
    }
    }</code>3. Set the <b>DataRowTemplate</b> property of your GridControl to an instance of your custom DataRow class:<code>grid.DataRowTemplate = new MyDataRow();</code>

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.