Home Forums WinForms controls Xceed Grid for WinForms Conditional Backcolor

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

    Can I conditionally change the back color of a datarow based on the value of a certain column without looping through the whole grid?

    Thanks in advance.

    Imported from legacy forums. Posted by San Fe (had 2317 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes you could. Try this (untested) code:<code>myGrid.DataRowTemplate.Cells[“myColumn”].ValueChanged += new EventHandler(myColumn_ValueChanged);
    private void myColumn_ValueChanged(object sender, EventArgs e){
    DataCell cell = sender as DataCell;
    DataRow row = cell.ParentRow as DataRow;
    if (cell.Value == someValue)
    row.BackColor = someColor;
    else
    row.ResetBackColor();
    }</code>

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

    User (Old forums)
    Member
    Post count: 23064

    Tommy,
    Thanks for your response. That just worked fine.

    Thanks

    Imported from legacy forums. Posted by San Fe (had 3448 views)

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