Articles in this section
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.

Showing formatting DoubleTextBox cellvalues

 

Sample Link: Formatting DoubleTextBox value

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied