Question

I want to add a feature to my MenuStrip where I want there to be an option where you can hover over or press the menu option to open recently opened projects .

File---> Recently Opened Projects---> {List of projects.....}

The same kind of option/menu that exists in Microsoft office products (e.g. word 2007).

I know how to get an array of the file names. I just need to know how to put the array of the names at the Sub MenuStrip.

Was it helpful?

Solution

You can add them dynamically in code:

    private void menuItem_Click(object sender, EventArgs e)
    {
        ToolStripMenuItem item = new ToolStripMenuItem();
        item.Text = "your file name";
        item.Click += new EventHandler(yourEventHandler);
        menuItem.DropDownItems.Add(item);
    }

OTHER TIPS

You need to create ToolStripMenuItems in a loop and call DropDownItems.Add to add them to your parent menu item.
In the loop, you should add a handler to their Click event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top