111,125
社区成员
发帖
与我相关
我的任务
分享
public class PoorBox : RichTextBox
{
const int DBCLCIK = 0x0203;//双击
const int GETFOCUS = 0x0007;//得到焦点
protected override void WndProc(ref Message msg)
{
if (msg.Msg == DBCLCIK || msg.Msg == GETFOCUS)
{
return;
}
base.WndProc(ref msg);
}
}
//RichTextBox Enter 事件中
tbHide.Focus();
public class NewTextBox : RichTextBox
{
protected override void WndProc(ref Message msg)
{
if (msg.Msg == 0x0300 || msg.Msg == 0x0301) return; // 禁止复制或剪切
base.WndProc(ref msg);
}
}
这样试试,不过你一旦输入字符,光标又有了
[DllImport("user32", EntryPoint = "HideCaret")]
private static extern bool HideCaret(IntPtr hWnd);
private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
{
HideCaret(((RichTextBox)sender).Handle);
}