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

Formatting in QueryValue event

Hi,
We are using Syncfusion Essential Studio 4.4.0.55 (GridGroupingControl).
I need to show the text in cell as red depending on the values in other cells of that row. I will get this values in QueryValue event only and formatting of cells can be done in QueryCellStyleInfo event. Could you please help me in setting the formatting on cells in QueryValue.
Also i need to change the header text in ExtraSection(custom headers) in QueryValue.

3 Replies

AD Administrator Syncfusion Team March 12, 2007 08:58 PM UTC

Hi Anand,

The QueryValue event is occured when the value for the unbound field descriptor or records are return. If you want to format the cell, you need to handle the QueryCellStyleInfo event of the grid and set the Style.Format to required format in a grid. Here is a code snippet

private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "ImgChk")
{
e.Style.CellValueType = typeof(int);
e.Style.CellValue = 76000;
e.Style.Format = "C";
e.Handled = true;
}
}

Also refer the TextFormat browser sample for more details.
\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\Appearance\TextFormat\cs

Best regards,
Haneef


AD Administrator Syncfusion Team March 20, 2007 07:42 AM UTC

Hi Haneef,
How can I get the value of the cell which is getting painted and other cells as well for the same row in QueryCellStyleInfo so that I can decide what formatting has to be applied to the text of the painting cell.
Please help. Many Thanks in advance.


AD Administrator Syncfusion Team March 20, 2007 09:27 PM UTC

Hi Anand,

You can use the Record.GetValue method to get the value of the cells in a grid. Here is a code snippet

private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
Element el = e.TableCellIdentity.DisplayElement;
if(el.Kind == DisplayElementKind.Record )
{
GridRecordRow row = el as GridRecordRow ;
if( row != null && row.ParentRecord != null)
{
object obj = row.ParentRecord.GetValue("Col3");
Console.WriteLine(obj);
}
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon