// Efficient adminstration of editors per format private Dictionary mEditorCache = new Dictionary(); private void mGridBerechnung_InitializeRow(object sender, InitializeRowEventArgs e) { IFormattable formattableInstance1 = new PercentageFormat(); IFormattable formattableInstance2 = new NumericFormat(); SetCellEditors(e.Row, formattableInstance1); } /// /// Set cell editor with appropriate formatting. /// private void SetCellEditors(UltraGridRow row, IFormattable formattable) { // editor already cached? UltraNumericEditor editor; if (mEditorCache.TryGetValue(pFormattable.FormatString, out editor)) { // editor cached } else { // new editor instance editor = new UltraNumericEditor(); editor.NumericType = NumericType.Double; editor.MaskInput = "{double:-8.6}"; editor.PromptChar = ' '; editor.FormatString = pFormattable.FormatString; // add to cache mEditorCache.Add(pFormattable.FormatString, editor); } // Editor den betreffenden Zellen zuweisen row.Cells["Value"].EditorComponent = editor; } public interface IFormattable { string FormatString {get;} } private class PercentageFormat : IFormattable { public string FormatString {get; private set;} internal PercentageFormat() { FormatString = "#0.##%"; } } private class NumericFormat : IFormattable { public string FormatString {get; private set;} internal NumericFormat() { FormatString = "###,##0.##"; } }