private void UpdateServersMenu() { var items = ServersItem.MenuItems; while (items[0] != SeperatorItem) { items.RemoveAt(0); } int i = 0; foreach (var strategy in controller.GetStrategies()) { MenuItem item = new MenuItem(strategy.Name); item.Tag = strategy.ID; item.Click += AStrategyItem_Click; items.Add(i, item); i++; } // user wants a seperator item between strategy and servers menugroup items.Add(i++, new MenuItem("-")); int strategyCount = i; Configuration configuration = controller.GetConfigurationCopy(); foreach (var server in configuration.configs) { MenuItem item = new MenuItem(server.FriendlyName()); item.Tag = i - strategyCount; item.Click += AServerItem_Click; items.Add(i, item); i++; } foreach (MenuItem item in items) { if (item.Tag != null && (item.Tag.ToString() == configuration.index.ToString() || item.Tag.ToString() == configuration.strategy)) { item.Checked = true; } } }