Hi,
I am novice Infragistics developer.
I have a basic question,As per our business requirement we need to show "BLANK" value for all the float/Int columns having value "0"
How can this be accomplished with UltraGrid?
Thanks,
Shashank
The FormatInfo will not be called unless the Format property is also set.
That's the only reason I can think of why it would not be called.
i use this way, but its not work for me!
i created customFormatter and set column properties, but this line will never called:
if (formatType == typeof(ICustomFormatter)) return this;
why??
I would use a custom format provider for this.
Firstly, create a provider class:
Public Class NumberFormatProvider : Implements IFormatProvider, ICustomFormatter
Public Function GetFormat(ByVal formatType As System.Type) As Object Implements System.IFormatProvider.GetFormat If (formatType Is GetType(ICustomFormatter)) Then Return Me Else Return Nothing End If End Function
Public Function Format(ByVal fmt As String, ByVal arg As Object, ByVal formatProvider As System.IFormatProvider) As String Implements System.ICustomFormatter.Format Try If (arg.GetType() IsNot GetType(Integer)) Then Return "" Else Dim value As Integer = DirectCast(arg, Integer) If (value = 0) Then Return "BLANK" Else Return value.ToString(fmt) End If End If Catch ex As Exception Return ex.Message End Try End Function
End Class
Then, set your column properties to use it:
This should work for Integers, you'll need to modify it to also work with floats.
This is obviously VB.NET as that's the project I had open at the time. If you need a C# version let me know.
Cheers,
Andy.
If you actually want to show "BLANK" in the cell instead of 0, you have two options. The first is to use a DataFilter, examples of which can be found in the Knowledge Base. Your other options is to create an unbound string column and to hide the real column; in the InitializeRow event you would copy over the values from the real column to the unbound one, adding "BLANK" instead of 0 when you encounter it. Of course, the downside to the latter approach is that since you have a string column, you lose some of the benefits of dealing with a strictly numeric type; you might be able to work around that by using a numeric mask input on the column.
-Matt