本文介绍了改变内置的ContextMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个继承自ComboBox的控件,我想在该组合框的ContextMenu中添加一个

条目。我没有问题,如果我从头开始创建一个全新的ContextMenu,但我更愿意只需将我的MenuItem添加到现有的内置ContextMenu上(剪切,复制,

粘贴等):


_RemoveMRUItemMenu = New MenuItem

_RemoveMRUItemMenu.Text ="& ;删除项目

_RemoveMRUItemMenu.Enabled = False


MyBase.ContextMenu.MenuItems.Add(_RemoveMRUItemMen u)


AddHandler _RemoveMRUItemMenu.Click,AddressOf

RemoveCurrentMRUItem

这不起作用; MyBase.ContextMenu返回Nothing,即使

*是*现有的ContextMenu(内置的)。


是编写代码的唯一方法手动执行通常的TextBox

上下文菜单命令?或者我可以写一个继承自

的ContextMenu类似TextBoxContextMenu的东西吗?


谢谢,


g 。

I''m writing a control inheriting from ComboBox, and I''d like to add an
entry to the ContextMenu for that combo box. I have no problem if I
create an entirely new ContextMenu from scratch, but I''d prefer just to
tack my MenuItem on to the existing, built-in ContextMenu (Cut, Copy,
Paste, etc.):

_RemoveMRUItemMenu = New MenuItem
_RemoveMRUItemMenu.Text = "&Remove Item"
_RemoveMRUItemMenu.Enabled = False

MyBase.ContextMenu.MenuItems.Add(_RemoveMRUItemMen u)

AddHandler _RemoveMRUItemMenu.Click, AddressOf
RemoveCurrentMRUItem
This doesn''t work; MyBase.ContextMenu returns Nothing, even though
there *is* an existing ContextMenu (the built-in one).

Is the only way to write code to manually perform the usual TextBox
context menu commands? Or can I write a ContextMenu inheriting from
something like "TextBoxContextMenu"?

Thanks,

g.

推荐答案




这篇关于改变内置的ContextMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:28