Is RichTextBox.AutoWordSelection broken?

I am writing a Windows Forms application in C # and I am creating a RichTextBox (via code, not the designer). I set the AutoWordSelection property to false, but when I select the material in the field, it still goes over to word boundaries, plus a space. Is this a .NET flaw or am I doing it wrong?

+5
source share
4 answers

Using .NET 3.5 I still have this problem. This was reported by Microsoft and tagged “Wont Fix” in 2005. This is the latest news that I can find in this issue.

Here is the MS Connect error report: http://connect.microsoft.com/VisualStudio/feedback/details/115441/richtextboxs-autowordselection-property-does-not-work-correctly#details

Here is another 2010 post about another person who noticed a problem: http://sonicflare.net/2010/01/10/shipped-bug-feature/#more-192

---------- UPDATE -------------

I earned by adding the additional value AutoWordSelection = False to the Form Load event.

   public Form1()
    {
        InitializeComponent();
        rich = new RichTextBox();
        rich.Size = new Size(150, 50);
        rich.Text = "Ignoring a bug for five years does not make it a undocumented feature.";
        rich.Location = new Point(20, 20);
        rich.AutoWordSelection = false;
        this.Controls.Add(rich);
    }

private void Form1_Load(object sender, EventArgs e)
{
    this.BeginInvoke(new EventHandler(delegate
    {
        rich.AutoWordSelection = false;
    }));
}
+14
source

RichTextBox TabControl. , Designer . , , . AutoWordSelection False . , True, False .

Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
    RichTextBox1.AutoWordSelection = True
    RichTextBox1.AutoWordSelection = False
End Sub
+1

. , , . , , .

, . -1 . MouseDown . , , .

MouseMove , , ControlStartStart SelectionLength . , , .

, .

0

I also came across this, but using a tab editor with multiple RTBs. In this case, you can implement a workaround by setting the property AutoWordSelectionto Falsein the code block that creates the RichTextBox. For example:

Private Sub CreateNewRTBObject(ByVal items() As String)
    Try
        For Each s As String In items
            If Not FilePaths.Contains(s) Then
                rtb = New myRTB(s)
                rtb.AutoWordSelection = False
            End If
        Next
        tabs.SetTabWidth()
    Catch ex As Exception
        MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
    End Try
End Sub
0
source

All Articles