using Krypton.Toolkit; using System.Reflection; namespace System { public static class KryptonListItemConvertor { public static KryptonListItem[] ToKryptonListItem(IList list, string display, string value) { if (list == null || list.Count == 0) return null; List l = new List(); KryptonListItem kryptonListItem; Type elementType = typeof(T); int i = 0; Dictionary keyValues = new Dictionary(); foreach (T item in list) { kryptonListItem = new KryptonListItem(); foreach (PropertyInfo property in elementType.GetProperties()) { if (property.Name == display) { kryptonListItem.ShortText = property.GetValue(item, null).ToString(); l.Add(kryptonListItem); } if (property.Name == value) { keyValues.Add(i, property.GetValue(item, null)); } } kryptonListItem.Tag = keyValues; i++; } return l.ToArray(); } public static KryptonListItem[] ToKryptonListItem(T[] list, string display, string value) { if (list == null || list.Length == 0) return null; return ToKryptonListItem(list.ToList(), display, value); } } }