簡體   English   中英

C#RichTextBox禁用自動塊選擇

[英]C# RichTextBox disable auto block selection

我無法對RichTextBox中的文本進行部分選擇,如何禁用自動選擇?

在此處輸入圖片說明

this.txtMSInput = new System.Windows.Forms.RichTextBox();
this.txtMSInput.DetectUrls = false;
this.txtMSInput.Location = new System.Drawing.Point(6, 31);
this.txtMSInput.Name = "txtMSInput";
this.txtMSInput.Size = new System.Drawing.Size(279, 202);
this.txtMSInput.TabIndex = 43;
this.txtMSInput.Text = "";

找到了答案,這是RichTextBox錯誤。

來自https://stackoverflow.com/a/3679036/10767810

AutoWordSelection屬性實現中存在一個愚蠢的錯誤。 解決方法同樣愚蠢。 將新類添加到您的項目中,然后粘貼以下代碼。 編譯。 將新控件從工具箱的頂部拖放到您的窗體上,替換現有的RTB。

using System;
using System.Windows.Forms;

public class FixedRichTextBox : RichTextBox {
    protected override void OnHandleCreated(EventArgs e) {
        base.OnHandleCreated(e);
        if (!base.AutoWordSelection) {
            base.AutoWordSelection = true;
            base.AutoWordSelection = false;
        }
    }
}

我在此MSDN Library頁面的底部留下了注釋,其中包含該錯誤的詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM