Grid showing formatted value in edit mode

Hi, I am sure this is a common one. I am using an editable grouping grid on one of my forms. For display purpose, I need to show numeric columns to 0 decimal places. But when the user clicks on the cell for editing, i need to show 2 decimal places. I cant seem to find a straightforward way to do it! Any help would be great -faraz

1 Reply

AD Administrator Syncfusion Team March 11, 2005 08:45 PM UTC

One way I think you can do this is to handle the TableControlCurrentCellInitializeControlText, and there format the string that is used to initizize the control text. Here is a little snippet. You would have to ID the cell somehow where you want this formatting to happen. Here the code just formats all doubles.
private void gridGroupingControl1_TableControlCurrentCellInitializeControlText(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellInitializeControlTextEventArgs e)
{
	if(e.Inner.CellValue is double)
	{
		e.Inner.ControlText = string.Format("{0:F2}", e.Inner.CellValue);
	}
}

Loader.
Up arrow icon