只能通过WINDOWS API的HideCaret函数来实现
HideCaret函数的申明:
[DllImport(
"
user32
"
, EntryPoint
=
"
HideCaret
"
)]
private
static
extern
bool
HideCaret(IntPtr hWnd);
为TextBox添加MouseDown事件:
textbuttons[i].MouseDown
+=
new
MouseEventHandler(FrmSend_MouseDown);
void
FrmSend_MouseDown(
object
sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
HideCaret(((TextBox)sender).Handle);
}
本文介绍了一个使用Windows API的HideCaret函数隐藏TextBox中光标的方法。通过为TextBox添加MouseDown事件并调用HideCaret函数,可以实现在点击TextBox时隐藏光标的效果。
993

被折叠的 条评论
为什么被折叠?



