Prevent Blinking Cursor in Textbox

后端 未结 7 1331
庸人自扰
庸人自扰 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:12

    Putting the hideCaret function inside the TextChanged event will solve the problem:

    [DllImport("user32.dll")]
    static extern bool HideCaret(IntPtr hWnd);
    
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        HideCaret(textBox1.Handle);
    }
    

提交回复
热议问题