Posts

Showing posts from October, 2015

TreeView Traversing in c#

To get tree view structure in C# language according to business logic

privateList<string> GetAllSubItems(string ItemId)  {     List<string> ItemIds = newList<string>();     List<ClassName> subItems = null;     var objController = new StorageManager();     subItems = objController.GetAllItemPreAssemblyPickupLocationItem();     System.Func<string, IEnumerable<ClassName>,                  IEnumerable<ClassName>> getItems = null;     getItems = (strItemId, Items) => Items.Where(x => x.ItemId == strItemId).     SelectMany(x => getItems(x.SubItemId, Items).Concat(new ClassName[] { x }));     var allItems = getItems(ItemId, subItems);     if (allItems != null && allItems.Count() > 0)         allItems.ToList().ForEach(x => { ItemIds.Add(x.ItemId); ItemIds.Add(x.SubItemId); });     return ItemIds.Distinct().ToList(); }