目录

C中,如何隐藏TextBoxRichTextBox中闪烁的光标

目录

C#中,如何隐藏TextBox/RichTextBox中闪烁的光标?

方案:调用Windows API

1> 将TextBox的TabStop设置为false;

2> 在程序中相应位置加入下列代码

using System.Runtime.InteropServices;

……

[DllImport(“user32”, EntryPoint = “HideCaret”)]

private static extern bool HideCaret(IntPtr hWnd);

……

在TextBox的MouseDown事件中添入:

HideCaret(((TextBox)sender).Handle);