Prevent Blinking Cursor in Textbox

后端 未结 7 1309
庸人自扰
庸人自扰 2020-12-09 22:33

In a textbox, how can u prevent the display of the blinking cursor when you click on it?

I did read in some forums that there is call to a particular api but when i

7条回答
  •  [愿得一人]
    2020-12-09 23:10

    If you want to disallow editing on the textbox, set it's ReadOnly property to true.

    If you want to allow editing but still hide the caret, call the Win32 API exactly as specified:

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    static extern bool HideCaret(IntPtr hWnd);
    
    ...
    
    HideCaret(myTextBox.Handle);
    

提交回复
热议问题