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

handling zeros in GCC

hi,

I am using GCC bound to a custom entity collction.

I am having following two problems.

1) If the entity is having 0 as value for a property of type integer OR double, that column should be shown as a blanked in Grid. by default it displays the value held by property i.e 0.

2)There is another integer property which has say value 1234 and in another instance say 56789. When i want to show them in grid,I want to mask the values so that zeros should be appended to the begining of number so that total number of visible digits are eight. so in my example when i display the values in grid, they should be shown as 00001234 and 00056789 respectively.

Please help me with a solution for above

Thanks

Dinesh

1 Reply

HA haneefm Syncfusion Team April 19, 2007 04:02 PM UTC

Hi Dinesh,

If you want to display the formatted text in a cell then subscribe the QueryCellFormattedText event and set the e.Text to your new formatted value and then set e.Handled to TRUE to cancel default format. Here is a code snippet to show this

private void TableModel_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
GridTableCellStyleInfo style = e.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record
&& style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "ID" )
{
if( e.Style.Text == "0" )
e.Text = "Welcome";
else
e.Text = string.Format("{0:000000.##}",e.Style.CellValue);
e.Handled = true;
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon