/// <summary> /// Adds the plans as toolstrip items to the list. /// </summary> /// <param name="plans">The plans.</param> /// <param name="list">The list.</param> /// <param name="initialize">The initialize.</param> /// <exception cref="System.ArgumentNullException"></exception> public static void AddTo(this IEnumerable <Plan> plans, ToolStripItemCollection list, Action <ToolStripMenuItem, Plan> initialize) { plans.ThrowIfNull(nameof(plans)); list.ThrowIfNull(nameof(list)); initialize.ThrowIfNull(nameof(initialize)); //Scroll through plans foreach (Plan plan in plans) { ToolStripMenuItem item; using (ToolStripMenuItem planItem = new ToolStripMenuItem(plan.Name)) { initialize(planItem, plan); item = planItem; } list.Add(item); } }