MV Sreedhar
MV Sreedhar

Reputation: 359

RichTextBox Text alignment issue with .NET4.8

When compared the text alignment with RichTextBox, behavior has changed from .Net4.6.1 to .Net4.8.

Any help on how the earlier behavior of .Net 4.6.1 can be achieved in .Net4.8?

enter image description here

public Form1()
    {
        InitializeComponent();

        
        RichTextBox richTextBox1 = new RichTextBox()
        {
            Width = 300,
            Height = 20,
            Location = new Point(100, 100)
        };

        richTextBox1.Text = "中文_Dummy_Text";

        TextBox textBox = new TextBox()
        {
            Width = 300,
            Height = 20,
            Location = new Point(100, 200)
        };

        textBox.Text = "中文_Dummy_Text";

        this.Controls.Add(richTextBox1);
        this.Controls.Add(textBox);

    }

Upvotes: 0

Views: 374

Answers (2)

MV Sreedhar
MV Sreedhar

Reputation: 359

Setting multiline property to false also restores the earlier behavior of RTB

richTextBox1.Multiine = false

Upvotes: 0

MV Sreedhar
MV Sreedhar

Reputation: 359

Adding the runtime setting in App.Config (as below) reverted back to the older RTB in .NET 4.8.

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
        </startup>
      <runtime>
         <AppContextSwitchOverrides value="Switch.System.Windows.Forms.DoNotLoadLatestRichEditControl=true"/>
      </runtime>
    
    </configuration>

Upvotes: 2

Related Questions