如何在上下文菜单条上的子项上添加事件? C#
for (int i = 0; i < client.Folders.Count; i++)
{
(ContextMenuListView.Items[1] as ToolStripMenuItem).DropDownItems.Add(client.Folders[i].Name);//add Folder to Move To
(ContextMenuListView.Items[2] as ToolStripMenuItem).DropDownItems.Add(client.Folders[i].Name);
}
如何获取 Items[1] 或 Items[2] 中的子项目?
for (int i = 0; i < client.Folders.Count; i++)
{
(ContextMenuListView.Items[1] as ToolStripMenuItem).DropDownItems.Add(client.Folders[i].Name);//add Folder to Move To
(ContextMenuListView.Items[2] as ToolStripMenuItem).DropDownItems.Add(client.Folders[i].Name);
}
how to I get subitem in Items[1] or Items[2] ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ToolStripItemCollection.Add(string)
(DropDownItems.Add()) 将返回新的 ToolStripItem ...另一方面,所有其他子项均由
ToolStripItemCollection DropDownItems
引用因此,获取两个创建的项目的简单方法是:
将成为:
或访问所有子项目:
或访问特定子项目:
ToolStripItemCollection.Add(string)
(DropDownItems.Add()) will return the new ToolStripItem ...on the other hand, all other sub items are referenced by the
ToolStripItemCollection DropDownItems
so the easy way to get the two created items is:
would become:
or to access all sub items:
or to access a specific sub item: