How to disable cursor in textbox?

后端 未结 10 1104
执笔经年
执笔经年 2020-12-09 02:41

Is there any way to disable cursor in textbox without setting property Enable to false? I was trying to use ReadOnly property but despite the fact that I can\'t write in tex

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 02:52

    In C# you can disable the cursor in a textbox by temporarily disabling and then re-enabling the text box whenever it receives the focus. Note there is no need to make the textbox read only if using this method. For example:

    private void TextBox_Enter(object sender, EventArgs e)
    {
      TextBox.Enabled = false;
      TextBox.Enabled = true;
    }
    

提交回复
热议问题