Home Forums WinForms controls Xceed Grid for WinForms Changing Background Color of Row according to data on initial Form Load.

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

    Hi,

    I have a Windows Form containing a Grid Control which displays a simple list of values from DB.

    I would like to change the background color of  the row according to the value of data retrieved from DB on initial load of the form.

    ex: if  value of column is YES the row should be gray in color.

    Any help would be appreciated.

    Thanks,

    Ravs 

     

     

     

    Imported from legacy forums. Posted by Ravs (had 562 views)

    User (Old forums)
    Member
    Post count: 23064

    Use the AddingDataRow event, and set the color accordingly in the event handler.

    e.g:

    private void Form1_Load(object sender, EventArgs e)

    {

        gridControl1.AddingDataRow +=

    new AddingDataRowEventHandler(gridControl1_AddingDataRow);

    }

    void gridControl1_AddingDataRow( object sender, AddingDataRowEventArgs e )

    {

        if( ( int )e.DataRow.Cells[ “ShipperID” ].Value == 2 )

            e.DataRow.BackColor =

    Color.Gray;

    }

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks a lot!

    It worked.

    Imported from legacy forums. Posted by Ravs (had 939 views)

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