Category / Section
How to set the format of a DoubleTextBox celltype when the cellvalue is 0 in WinForms GridControl?
1 min read
By default, the value 0 will be displayed as 0.00 in the DoubleTextBox cell. To customize the display format of cell value, use the DisplayText property in the DrawCellDisplayText event.
//Event Subscription
gridControl1.DrawCellDisplayText += GridControl1_DrawCellDisplayText;
//Event Customization
private void GridControl1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellType== CustomCellTypes.DoubleTextBox.ToString() && e.DisplayText== "0.00")
{
e.DisplayText = "0";
}
}The
screenshot below illustrates the format of grid cells.

Sample Link: Formatting DoubleTextBox value