How to hide the caret in a RichTextBox?

后端 未结 9 1705
[愿得一人]
[愿得一人] 2020-12-31 15:10

Just like the title: I\'ve searched the web for an answer, but i was not able to find a way to hide the caret of a RichTextBox in VB.NET.

I\'ve tried to set the Rich

9条回答
  •  旧巷少年郎
    2020-12-31 15:58

    This works for me :

    public class RichTextLabel : RichTextBox
    {
        public RichTextLabel()
        {
            base.ReadOnly = true;
            base.BorderStyle = BorderStyle.None;
            base.TabStop = false;
            base.SetStyle(ControlStyles.Selectable, false);
            base.SetStyle(ControlStyles.UserMouse, true);
            base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
    
            base.MouseEnter += delegate(object sender, EventArgs e)
            {
                this.Cursor = Cursors.Default;
            };
        }
    
        protected override void WndProc(ref Message m) {
            if (m.Msg == 0x204) return; // WM_RBUTTONDOWN
            if (m.Msg == 0x205) return; // WM_RBUTTONUP
            base.WndProc(ref m);
        }
    }
    

    I hope it helps

提交回复
热议问题