Hi,
I am using ultrawingrid and I am calculating summaries by doing:
summary1.DisplayFormatDisplayFormat = "{0:0.00}";
Now if in my grid if all the cell values of particular column is coming as blank, then it showing summary value for that column is 0.00.
However, instead of showing 0.00, I want to show blank in summary cell for that column.
Thanks and Regards,Rosy Malhotra
For this I would use a custom format provider. Declare a class like this:
public class NumberFormatProvider : IFormatProvider, ICustomFormatter
{
#region IFormatProvider Members
public object GetFormat(Type formatType)
if (formatType == typeof(ICustomFormatter))
return this;
else
return null;
}
#endregion
#region ICustomFormatter Members
public string Format(string format, object arg, IFormatProvider formatProvider)
try
if (arg.GetType() != typeof(float))
return "Unexpected data type"; // The number is not of the
// expected type so return a message.
float value = (float)arg;
if (value == 0f)
return string.Empty; // If the number is 0 then return an
// empty string.
return value.ToString(format); // Return the number formatted
// according to format string.
catch (Exception ex)
return ex.Message;
Then specify it in the SummarySettings:
summary1.DisplayFormatProvider = new NumberFormatProvider();
In this code I have assumed your using a 'float' data type. Change the type in the four places it's specified if necessary (or make the class more flexible by accepting more types).
Andy.