Home Forums WinForms controls Xceed Grid for WinForms Define cell style per datarow style

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

    I have a grid for which I have defined 2 dataRowStyle’s, so that I can get alternating row colours. However, I’d also like to adjust the colour of a particular column in the grid as well to have different colours.

     

    e.g;

    row0.BackColor = White

    row1.BackColor = Grey

     

    But in row0.column5 I want .BackColour = PaleYellow

    and in row0.column6 I want .BackColour = DarkYellow

     

    Is this setup possible? I can’t work it out in the grid designer. I thought about writing a handler for the Cell.Paint event to modify the cell colours, but I can’t work out how to determine the original dataRowStyle for a cell.

     

    Solving either of those problems will help.

     

    rJ

    Imported from legacy forums. Posted by RJ (had 1355 views)

    User (Old forums)
    Member
    Post count: 23064

    This can be done by deriving from the DataRow and DataCell classes, in which you can override the GetDisplayVisualStyle method, so to get the color you want on the cell according to the parent row color.

     I have attached a sample application demonstrating this.

    Imported from legacy forums. Posted by André (had 649 views)

    User (Old forums)
    Member
    Post count: 23064

    Cool thanks for that.

    Imported from legacy forums. Posted by RJ (had 937 views)

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