Using system;
Using system. Windows. forms;
Using system. runtime. interopservices;
Namespace windowsapplication1
{
Public partial class form1: Form
{
[Dllimport ("user32.dll")]
Static extern bool createcaret (intptr hwnd, intptr hbitmap, int nwidth, int nheight );
[Dllimport ("user32.dll")]
Static extern bool showcaret (intptr hwnd );
Public form1 ()
{
Initializecomponent ();
Richtextbox1.gotfocus + = new eventhandler (richtextbox?gotfocus );
}
Private void richtextboxinclugotfocus (Object sender, eventargs E)
{
This. begininvoke (New methodinvoker (changecaret ));
}
Private void richtextbox#selectionchanged (Object sender, eventargs E)
{
This. changecaret ();
}
Private void richtextbox#mousedown (Object sender, mouseeventargs E)
{
This. changecaret ();
}
Private void changecaret ()
{
Createcaret (this. richtextbox1.handle, intptr. Zero, 10, 15 );
Showcaret (this. richtextbox1.handle );
}
Private void richtextbox1_keyup (Object sender, keyeventargs E)
{
This. changecaret ();
}
}
}