How to display conditionally display value in a cell

Hello everyone.
I am using sfDataGrid to just display records. I have a numericcolumn and datecolumn among other columns.
For the numericcolumn, I want to display empty string in the numericcolumn if the underlying value equals 0
I want to find out if my requirement is possible. If it's, how should I go about it.
Thanks for the usual

3 Replies

MA Mohanram Anbukkarasu Syncfusion Team December 3, 2020 09:01 AM UTC

Hi Paul, 
  
Thanks for contacting Syncfusion support.  
  
You can achieve your requirement to display empty string instead of zero in the GridNumbericColumn by using DrawCell event as shown in the following code example.  
  
Code example :  
  
this.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell;  
  
private void SfDataGrid1_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e) 
{ 
    if(e.Column.GetType() == typeof(GridNumericColumn) && e.DisplayText == "0") 
    { 
        e.DisplayText = string.Empty; 
    } 
} 
  
  
Please let us know if you require further assistance from us.  
  
Regards, 
Mohanram A. 



PA Paul December 4, 2020 03:08 PM UTC

Hello Mohanram, 

Thanks for the prompt response.  Your suggestion worked like magic. 

I am indeed very grateful. 

Thanks 


MA Mohanram Anbukkarasu Syncfusion Team December 7, 2020 04:35 AM UTC

Hi Paul, 

Thanks for the update. 

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 

Regards, 
Mohanram A. 


Loader.
Up arrow icon