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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cell Formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

41916 Mar 14,2006 10:46 PM UTC Mar 15,2006 05:06 PM UTC WinForms 2
loading
Tags: GridControl
Hui Zhong
Asked On March 14, 2006 10:46 PM UTC

I want to format the cellvalue to the format like #.000. I tried several events, like QueryCellInfo.., it did not work. Please see the attached example code, and see what''s the problem. Thanks.

Forum_407350.zip

Administrator [Syncfusion]
Replied On March 15, 2006 11:38 AM UTC

Hi Hui, This happens, because the ( e.Style.CellValue = dt.Rows[e.RowIndex - 1][e.ColIndex – 1] ) value of the datatable that is assigned to the cellvalue becomes a string by default. This causes the format not to be assigned. You can avoid this, by converting the value to double. Here is the code snippet. private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { if (e.RowIndex > 0 && e.ColIndex >= 4 ) { e.Style.CellValue = Convert.ToDouble(dt.Rows[e.RowIndex - 1][e.ColIndex - 1]); e.Style.Format = "##.000"; } } Let us know if this helps. Best regards, Madhan.

Hui Zhong
Replied On March 15, 2006 05:06 PM UTC

Thanks. It worked. >Hi Hui, > > This happens, because the ( e.Style.CellValue = dt.Rows[e.RowIndex - 1][e.ColIndex – 1] ) value of the datatable that is assigned to the cellvalue becomes a string by default. This causes the format not to be assigned. You can avoid this, by converting the value to double. Here is the code snippet. > > private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) >{ > if (e.RowIndex > 0 && e.ColIndex >= 4 ) > { > e.Style.CellValue = Convert.ToDouble(dt.Rows[e.RowIndex - 1][e.ColIndex - 1]); > e.Style.Format = "##.000"; > } >} > >Let us know if this helps. > >Best regards, >Madhan.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;