Home Forums WinForms controls Xceed Grid for WinForms Databind Backcolor

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

    How would I go about making a databound column that takes a supplied color value and binds the backcolor of each cell accordingly? Is this possible?

    Imported from legacy forums. Posted by hepkat (had 1889 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes this is possible. You need to subscribe to the AddingDataRow event of the GridControl, and set the cell BackColor in the event handler, by finding a way to make a corresponding between the value in the table and the Color structure.

    e.g.:

    //in Form_Load

    gridControl1.AddingDataRow += new AddingDataRowEventHandler(gridControl1_AddingDataRow);

    //Event handler

    private void gridControl1_AddingDataRow(object sender, AddingDataRowEventArgs e)
    {
    //if the color value in the table is a string representing a color (e.g. “red”)
    e.DataRow.Cells[ 0 ].BackColor = Color.FromName( e.DataRow.Cells[ 0 ].Value.ToString() );
    }

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

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