public static ListEditItemCollection GetCollection <T>(string caption) where T : struct { var collection = new ListEditItemCollection(); var values = GetKeysAndValues <T>(); if (!string.IsNullOrEmpty(caption)) { collection.Add(caption, 0); } collection.AddRange(values.Select(pair => new ListEditItem(pair.Value.ToString(), pair.Key)).ToList()); return(collection); }
protected override void SetupControl(WebControl control) { base.SetupControl(control); if (ViewEditMode == ViewEditMode.Edit) { ListEditItemCollection items = ((ASPxComboBox)control).Items; items.Clear(); ComboBoxItemsBuilder.Create() .WithPropertyEditor(this) .Build((enumerable, b) => items.AddRange(enumerable.Select(s => new ListEditItem(s)).ToList()), () => { var handledEventArgs = new HandledEventArgs(); OnItemsCalculating(handledEventArgs); return(handledEventArgs.Handled); }); } }