We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cell value from within QueryCellStyleInfo

private void _gridGroupingControl_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    // ???
}

What goes in ??? to get the current cell value based on information available in e?

Just in case there is a better way to do what I want, I want to format the data based on its value. Easy example, format negative numbers in red, or format today's date blue.


2 Replies

IB ian bradley May 28, 2012 10:12 AM UTC

Ok, think I've got it. Basically the grouping control has most of a grid control inside of it. So TableModel has most stuff on it I need.


AS Asarudheen S Syncfusion Team May 29, 2012 10:57 AM UTC

Hi Ian,

Thank you for your interest in Syncfusion products.

You can achieve the reported behavior through "QueryCellStyleInfo" event along with the following code.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
        {
            if (e.TableCellIdentity.ColIndex == 7 && e.TableCellIdentity.RowIndex>3)
            {
            
                    int value = int.Parse(e.Style.CellValue.ToString());
                    if (value < 0)
                    {
                        e.Style.BackColor = Color.Red;
                        e.Handled = true;
                    }
              
            }

            if (e.TableCellIdentity.ColIndex == 4 && e.TableCellIdentity.RowIndex > 3)
            {

                DateTime dt = (DateTime)e.Style.CellValue;

                if (dt.ToShortDateString()==DateTime.Now.ToShortDateString())
                {
                    e.Style.BackColor = Color.Blue;
                }
            }
        }

Sample:

http://www.syncfusion.com/downloads/Support/DirectTrac/94629/103719-171187510.zip

Please let us know if this helps.

Regards,
Asarudheen.

Loader.
Live Chat Icon For mobile
Up arrow icon