Search

.NET 4.0 / 4.5 incompatibility: WinForms / TableLayoutPanel by Roman.St

Closed
as Duplicate Help for as Duplicate

2
0
Sign in
to vote
Type: Bug
ID: 771954
Opened: 11/22/2012 7:28:52 AM
Access Restriction: Public
1
Workaround(s)
2
User(s) can reproduce this bug
The TableLayoutPanel shows controls in a different order in certain circumstances depending on whether .NET 4.0 or .NET 4.5 is installed.

I've found this in two separate places in our codebase now, causing compatibility issues for every user until they install an update we've issued.

More about this: http://roman.st/Article/Another-NET-4.5-incompatibility

I think this difference should be fixed even though 4.5 is out of testing now; doing so would at least enable users to upgrade to a patched .NET 4.5 to get compatibility for programs which are no longer maintained.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5

Steps to reproduce

Run the following C# program in .NET 4.0 and .NET 4.5 and compare the outputs:

using System.Drawing;
using System.Windows.Forms;

static class Program
{
    [System.STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        var pnl = new TableLayoutPanel { RowCount = 1, ColumnCount = 2 };
        pnl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
        pnl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
        pnl.RowStyles.Add(new System.Windows.Forms.RowStyle());

        pnl.Controls.Add(new Label { Text = "First!", ForeColor = Color.Maroon }, 0, 0);
        pnl.Controls.Add(new Label { Text = "Second...", ForeColor = Color.Blue }, 0, 0);

        var form = new Form { Font = new Font("Arial", 15) };
        form.Controls.Add(pnl);

        Application.Run(form);
    }
}

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

English

Actual results

The controls are shown in different order depending on the "highly compatible" upgrade being installed or not.

Expected results

The controls should be shown in the same order.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/28/2012 at 12:18 PM
Thank you for your feedback.
We were able to reproduce this issue and established that it is a duplicate of an issue reported here:
http://connect.microsoft.com/VisualStudio/feedback/details/767282/system-windows-forms-tablelayoutpanel-behavior-change-net-4-5-framework

Please follow that thread for further updates. We are planning to ship this fix in the upcoming update to .NET Framework 4.5 in the next couple of months. If you place controls into separate cells in your TableLayoutPanel, this workaround will work even after we ship the fix.

Please keep the feedback coming.
Thanks,
The Windows Forms Product Team
Posted by Microsoft on 11/22/2012 at 9:36 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/22/2012 at 7:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by TanyaSolyanik on 11/28/2012 at 12:27 PM
As a workaround, avoid placing controls into the same cell in your TableLayoutPanel. Additional advantage to this approach is a performance improvement when the form(or control) is loaded.