I have a contextMenuStrip that generated dynamical form data in a database. The data in the database has a group column and i want to use it to create Sub Menu's dynamically for the application. My problem is that it creates duplicate sub menu items and i want it grouped.
this is my List and Constructor.
List<Tuple<WebLinks>> WebLinksList = new List<Tuple<WebLinks>>();
class WebLinks
{
public string Name { get; set; }
public string Link { get; set; }
public string Group { get; set; }
}
So far this is the working code to build the context menu but I need this to change to the Group view and not just show the Name.
private void CreateMenu()
{
foreach (Tuple<WebLinks> wl in WebLinksList)
{
contextMenuStripMain.Items.Add(wl.Item1.Name);
}
contextMenuStripMain.Items.Add("-");
contextMenuStripMain.Items.Add("Settings");
contextMenuStripMain.Items.Add("Exit");
}
The above works fine but nothing is grouped, so i need to work in the "wl.Item1.Group" in somewhere but google was no help in my situation.
I tired This Stack Overflow and it gave me the duplicate Groups where i tried to filter it but with no luck. Hope I made sense.