FlowLayoutPanel returns incorrect PreferedSize - by pcbbc

Status : 


Sign in
to vote
ID 773432 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/4/2012 8:29:39 AM
Access Restriction Public


When a flow break is configured on adjacent controls within a FlowLayoutPanel, the Width computed size returned by PreferredSize can be incorrect.

In the simple case where a flow break is placed after EVERY control on the panel (i.e. one control per line) the computed width is ALWAYS incorrect.

In that case the preferred width returned should be equal to the widest control (plus any margins).  However the returned value appears to be the width of the widest control PLUS the width of the control which will be placed on the next line.
Sign in to post a comment.
Posted by Microsoft on 12/21/2012 at 2:37 PM
Thank you for reporting this issue. Customer feedback is a critical part of a successful, impactful software product. Unfortunately another part is the reality of schedules and the need to prioritize investments according to the objectives of the product. We have evaluated the issue that you have reported and at this point in the product's lifecycle, it does not meet the criteria to be addressed. This evaluation is carefully done and considers many aspects including the cost of the fix, implications of the change, and the number of reported instances of the issue.

Many customers have found it useful to discuss issues like this in the forums (http://www.microsoft.com/communities/forums/default.mspx) where Microsoft and other members of the community can recommend ways of achieving the behavior you are interested in.

Thank you,
The Windows Forms Product Team
Posted by Microsoft on 12/4/2012 at 6:16 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by pcbbc on 12/4/2012 at 5:17 PM
Looking at the .NET Framework code in Reflector (as you do ;) ) I see the problem seems to be the following code in the private xLayoutRow method of internal class SystemWindowsForms.Layout:

if (((num2 + 1) < endIndex) && CommonProperties.GetFlowBreak(elementProxy.Element))
    if (num == 0)
        flag2 = true;
        return empty;

The problem seems to be in the inner IF statement. Testing for num == 0 (i.e. first control on row) forces the code round for a second loop with flag2 set and evaluates the width of the next control (which should be on the next line as it is after a flow break) into the returned Size structure.

To me it looks like replacing the inner IF with just the following code would provide a fix?:
        return empty;
I can't quite see the point of handling the first control on a row with a flow break set any differently from any other?!

Posted by Microsoft on 12/4/2012 at 8:51 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)