How to show cursor in unfocused WinForms TextBox/RichTextBox?

前端 未结 3 2049
渐次进展
渐次进展 2021-01-14 03:34

I need to show cursor in RichTextBox control in WinForms application even when it\'s not in focus. How can I do this? I found only the way for WPF ( How to keep WPF TextBox

3条回答
  •  春和景丽
    2021-01-14 04:19

    I don't know what you are trying to achieve and how much is it really useful. But if it is just for visual purpose, write some thing like '|' in it. Its a bad, weird, awkward way or what ever you call it, for visual purpose it may work.

        public void blink()
        {
            while (true)
            {
                textBox1.Text = "|";
                Thread.Sleep(200);
                textBox1.Text = "";
                Thread.Sleep(200);
            }
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            Thread t1 = new Thread(new ThreadStart(blink));
            t1.Start();
        }
    

    I am not sure if I am giving is what you are asking, but to get accurate answer, you have to expose your need of this requirement.

    Hope it helps.

提交回复
热议问题