截图:
我用以下代码填充了上面截图中的菜单,但是愚蠢的我无法弄清楚如何在每个子项上创建点击事件,因为它们没有属性名称? :S 我的意图是点击,“Do and Do”,然后使用Process.Start(filename);
打开文件。请理解我,我是编程新手。:| 非常感谢!
private void loadViewTemplates(string path)
{
foreach (string file in Directory.GetFiles(path, "*.txt"))
{
ToolStripItem subItem = new ToolStripMenuItem();
subItem.Text = Path.GetFileNameWithoutExtension(file);
viewTemplatesToolStripMenuItem.DropDownItems.Add(subItem);
}
}