1

I have a ContextMenu like in this picture. Now i want to add where it says ".rtf" more MenuItems at runtime. I cant seem to make it...

Dim myContextMenu As ContextMenuStrip = Form1.mnuOptions
Dim myMenuItem As ToolStripMenuItem = myContextMenu.Items("SendTo")
Dim mySubMenuItem As New ToolStripMenuItem = myMenuItem.DropDownItems("File").SUBITEMS

This is how i imagine doing it, but it does not work of course because there is no ".subitems". What does it take to accomplish such an easy job?

And how can I set AddHandlers for each SubItem to a procedure?

4

1 回答 1

1

假设“文件”是带有该文本的菜单项的名称,您可以通过其名称直接访问它,并将下拉项添加到其集合中:

File.DropDownItems.Add("Pdf")

Add 重载之一允许您指示单击将触发的事件处理程序。

于 2013-08-08T04:03:31.570 回答