Welcome to the Xceed Community | Help
Community Search  

Changing Background Color of Row according to data on initial Form Load.

Sort Posts: Previous Next
  •  07-10-2008, 11:52 AM Post no. 13500

    Changing Background Color of Row according to data on initial Form Load.

    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 

     

     

     

  •  07-10-2008, 12:22 PM Post no. 13504 in reply to 13500

    Re: Changing Background Color of Row according to data on initial Form Load.

    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;

    }


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  07-10-2008, 1:50 PM Post no. 13507 in reply to 13504

    Re: Changing Background Color of Row according to data on initial Form Load.

    Thanks a lot!

    It worked.

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.