开发者

How to Disable some items of TextBox in C#?

Hi

I want to disable some items of the textbox like "Right to left reading order". I don't like these, but I do not found an explication why these are there and if is correct disable/remove them.

You can see here a little image开发者_Go百科 with the items that I want avoid.

http://www.imageupload.org/?d=96631C971

Any suggestions please.


While it's not possible to disable items from the default context menu, you can create a new one and customize the items for the textbox like this.

var contextMenu = new ContextMenu();
contextMenu.MenuItems.Add(new MenuItem("Copy", (s, ea) => textBox1.Copy()));
contextMenu.MenuItems.Add(new MenuItem("Paste", (s, ea) => textBox1.Paste()));
contextMenu.MenuItems.Add(new MenuItem("Undo", (s, ea) => textBox1.Undo()));
contextMenu.MenuItems.Add(new MenuItem("Select All", (s, ea) => textBox1.SelectAll()));
textBox1.ContextMenu = contextMenu;

Note: use contextMenu.MenuItems.Add(new MenuItem("-")) for separators.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜