RichTextBox-剪切\粘贴事件? [英] RichTextBox - Cut\Paste Event?
本文介绍了RichTextBox-剪切\粘贴事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我一直在网上搜索一种为RichTextBox控件创建剪切和粘贴事件的方法.有许多重写WndProc的示例.这是一个:
Hello everybody!
I have been searching all over the net for a way to create a cut and paste event for the RichTextBox control. There are many examples of overriding WndProc. Here is one:
Dim WM_PASTE As Integer = 770
Protected Overrides Sub WndProc(ByRef m As Message)
If (m.Msg = WM_PASTE) Then
MsgBox("Paste")
End If
MyBase.WndProc(m)
End Sub
由于某种原因,覆盖WndProc根本不执行任何操作.是否因为上面的示例适用于旧版本的VB?我正在使用VB2010.
如果上述代码不起作用,是否有人知道如何使用VB 2010为RichTextBox创建一个干净的剪切/粘贴事件?
谢谢!
For some reason overriding WndProc does not do anything at all. Is it because the above example is for older versions of VB? I am using VB 2010.
If the above code will not work does anybody know how to create a clean cut\paste event for a RichTextBox... using VB 2010?
Thanks!
推荐答案
您可以使用KeyDown事件检查Ctrl + V,还可以为自己的ContextMenu提供其自己的粘贴"选项.
You could use KeyDown event to check for Ctrl+V, and also supply your own ContextMenu with it''s own "Paste" option.
这篇关于RichTextBox-剪切\粘贴事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文