I currently have a custom format for a summary that when the value is zero it should display blank. Unfortunately I cant seem to get rid of the "Sum =" Ive tried modifying it on the summary change event of the grid and six ways from sunday inside the custom format. Code posted below:
In the init grid:
.Summaries.Add(SummaryType.Sum, .Columns(PayAmount)).DisplayFormatProvider = New NumberFormatProvider
Class NumberFormatProvider
Public Class NumberFormatProvider Implements IFormatProvider, ICustomFormatter Public Function Format(format1 As String, arg As Object, formatProvider As System.IFormatProvider) As String Implements System.ICustomFormatter.Format Try If TypeOf arg Is Decimal Then Return HandleOtherFormats("$0.00", arg) End If Catch ex As Exception Throw ex End Try End Function Public Function GetFormat(formatType As System.Type) As Object Implements System.IFormatProvider.GetFormat If formatType Is GetType(System.ICustomFormatter) Then Return Me Else Return Nothing End If End Function Private Function HandleOtherFormats(fmt As String, arg As Object) As String If TypeOf arg Is IFormattable AndAlso arg <> 0 Then Return DirectCast(arg, IFormattable).ToString(fmt, Me) Else Return "" End If End FunctionEnd Class
Please help!
Hello,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Could you please try the following code in order to get the desired behavior:
private void ultraGrid1_SummaryValueChanged(object sender, SummaryValueChangedEventArgs e) { e.SummaryValue.SummarySettings.DisplayFormat = "{0:###.00}"; }
Please let me know if this suits your needs.