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

FormulaCell default null value

I have added an additional formula like so: cellModel = Me.grd.CellModels("FormulaCell") cellModel.Engine.AddFunction("Data", New GridFormulaEngine.LibraryFunction(AddressOf Evaluate_Data)) It all works fine atm, however when I return the value "" the grid is displaying "0". Is there a way I can change this behaviour so it displays what I return? I have tried returning Nothing but it still shows "0".

2 Replies

AD Administrator Syncfusion Team October 11, 2004 12:19 AM

The empty string is specially treated as a 0 by the formula engine. If you return any string other than the empty string, you would see that string in the cell. So, if you return " " instead of "", you would see a blank in the cell. This would be the simplest thing to do. If you really need to see the cell display the empty string, you can handle the DrawCellDisplayText event and specifiy what text you want to see in the cell there.
Private Sub gridControl1_DrawCellDisplayText(sender As Object, e As GridDrawCellDisplayTextEventArgs)
   If e.Style.Text.ToUpper().StartsWith("=DATA(") And e.Style.FormattedText = "0" Then
      e.DisplayText = ""
      e.Cancel = True
   End If
End Sub ''gridControl1_DrawCellDisplayText

DE Denis October 11, 2004 04:41 PM

hmmm, I figured I might have to use the " " string to trick it. Handling the DrawCellDisplayText event wont work as it doesnt seem to allow for valid cases of "0". I am happy to use " " as it doesnt seem to be causing any issues. Thanks.

Live Chat Icon For mobile
Up arrow icon