[Mono-bugs] [Bug 81694][Nor] New - Controls moved to wrong location (layout logic bug)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon May 21 00:28:54 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by stmono at alienworks.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81694

--- shadow/81694	2007-05-21 00:28:54.000000000 -0400
+++ shadow/81694.tmp.624	2007-05-21 00:28:54.000000000 -0400
@@ -0,0 +1,195 @@
+Bug#: 81694
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details: Tested on Windows (.Net, Mono), openSUSE
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: stmono at alienworks.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Controls moved to wrong location (layout logic bug)
+
+Description of Problem:
+
+The layout logic for controls behave differently on .Net vs.
+Mono. I have included sample code that shows the problem. When a
+nested control is displayed on top of the main form, controls
+that are inside this control are shifted to the wrong location.
+
+In the sample, there are two buttons that are inside a UserControl-
+derived control (UserControl1).  The top-left button (button1) is 
+anchored to the top-left corner.  The bottom-right button (button2) is 
+anchored to the bottom-right corner. UserControl1 itself is anchored top-
+left only.
+
+In theory, when the form is displayed, no control should be moved at all. 
+When running the sample on .Net, this is indeed the case - no control is 
+moved.  When run on Mono (any OS), the bottom-right button is incorrectly 
+shifted completely out of view.  I have confirmed this by adding an event 
+handler to button2's "LocationChanged" event.  This event is never fired 
+on .Net (expected behavior), but is fired on Mono (incorrect behavior).
+
+Steps to reproduce the problem:
+1. Create a new C# application in VS 2005 and copy and paste the supplied 
+two classes of sample code into the individual classes. Basically there 
+is the Form1 class, and also a UserControl1 class.
+2. Compile and run the code on Windows on .Net
+3. Run the exact same executable on Mono (any OS).
+
+Actual Results:
+On Mono (any OS), button2 is shifted completely out of view. 
+The "LocationChanged" event is fired on Mono for button2, but not .Net.
+
+Expected Results:
+On Mono, button2 should not be moved at all, and should still be visible. 
+The event "LocationChanged" should not be fired at all, since the control 
+should never be moved (based on the layout settings).
+
+How often does this happen? 
+Every time
+
+Additional Information:
+Tested on Mono 1.2.4.  Tested on Windows .Net 2.0, Mono 1.2.4 on Windows 
+and Mono 1.2.4 on openSUSE. Code compiled on VS 2005.
+
+I can't create attachments so here are the two classes to 
+
+reproduce the problem:
+
+====== Form1.cs ======
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace App1
+{
+    public class Form1 : Form
+    {
+        private UserControl1 userControl1;
+    
+        public Form1()
+        {
+            InitializeComponent();
+        }
+
+        private void InitializeComponent()
+        {
+            this.userControl1 = new App1.UserControl1();
+            this.SuspendLayout();
+            // 
+            // userControl11
+            // 
+            this.userControl1.BackColor = 
+
+System.Drawing.Color.White;
+            this.userControl1.Location = new 
+
+System.Drawing.Point(13, 13);
+            this.userControl1.Name = "userControl11";
+            this.userControl1.Size = new 
+
+System.Drawing.Size(288, 238);
+            this.userControl1.TabIndex = 0;
+            // 
+            // Form1
+            // 
+            this.ClientSize = new System.Drawing.Size(399, 340);
+            this.Controls.Add(this.userControl1);
+            this.Name = "Form1";
+            this.ResumeLayout(false);
+        }
+    }
+}
+
+
+===== UserControl1.cs =====
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+namespace App1
+{
+    public class UserControl1 : UserControl
+    {
+        private Button button1;
+        private Button button2;
+    
+        public UserControl1()
+        {
+            InitializeComponent();
+
+            button2.LocationChanged += OnButton2LocationChanged;
+        }
+
+        private void OnButton2LocationChanged(object sender, 
+
+EventArgs e)
+        {
+            Console.WriteLine("button2 should NOT be moved 
+
+here!");
+        }
+        
+        private void InitializeComponent()
+        {
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(4, 
+
+4);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            // 
+            // button2
+            // 
+            this.button2.Anchor = 
+
+((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.Ancho
+
+rStyles.Bottom | 
+
+System.Windows.Forms.AnchorStyles.Right)));
+            this.button2.Location = new 
+
+System.Drawing.Point(210, 212);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 1;
+            this.button2.Text = "button2";
+            this.button2.UseVisualStyleBackColor = true;
+            // 
+            // UserControl1
+            // 
+            this.BackColor = System.Drawing.Color.White;
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Name = "UserControl1";
+            this.Size = new System.Drawing.Size(288, 238);
+            this.ResumeLayout(false);
+        }
+    }
+}


More information about the mono-bugs mailing list