怪事了,C# 窗口内所有TextBox控件(包括其他可以写字的控件)全都无法复制粘贴,这个问题相当纠结啊。其实,这个BUG已经发现了有一段时间了,但是一直没有时间去理会它。昨天BOSS要我解决它,折腾了好久,都没找到原因,今天终于解决了,所以记录一下方法,防止自己忘记。
起初,我一直以为是我自己重写的控件冲突了,导致按键被屏蔽了,于是昨天一天都在检查项目的控件,想不到白折腾。
真实的原因是:
Visual Studio 2010 自动生成 MDI 窗口的标准菜单,其中的编辑菜单包含了CTRL-A,CTRL-C,CTRL-V,CTRL-X 等快捷键,由于没有去实现这些快捷键,所以导致无法进行复制粘贴。
C# 窗口内所有TextBox控件(包括其他可以写字的控件)全都无法复制粘贴 的解决方法:
1、删除编辑菜单里面的快捷键。例如:打开窗口的 Designer 界面,例如我的 MDITest.Designer.cs,然后找到:
#e3e3e3;margin-top:5px;color:#000000;"> C# Code By wuleba.com
|
2 3 4 5 6 7 8 9 |
//
// cutToolStripMenuItem // this.cutToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject(“cutToolStripMenuItem.Image”))); this.cutToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; this.cutToolStripMenuItem.Name = “cutToolStripMenuItem”; this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); this.cutToolStripMenuItem.Size = new System.Drawing.Size(161, 22); this.cutToolStripMenuItem.Text = “剪切(&T)”; |
2、把所有的快捷键删除即可:
#e3e3e3;margin-top:5px;color:#000000;"> C# Code By wuleba.com
|
|
this.cutToolStripMenuItem.ShortcutKeys = ( (System.Windows.Forms.Keys) ( (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X) ) );
|
3、最终变成这样就可以了:
#e3e3e3;margin-top:5px;color:#000000;"> C# Code By wuleba.com
|
2 3 4 5 6 7 8 |
//// cutToolStripMenuItem
// this.cutToolStripMenuItem.Image = ( (System.Drawing.Image) (resources.GetObject (“cutToolStripMenuItem.Image”) ) ); this.cutToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; this.cutToolStripMenuItem.Name = “cutToolStripMenuItem”; this.cutToolStripMenuItem.Size = new System.Drawing.Size (161, 22); this.cutToolStripMenuItem.Text = “剪切(&T)”; |
飞度软件工作室 2012-06-29(发于 吾乐吧软件站)