[Mono-bugs] [Bug 79595][Maj] New - The Form.Controls.Clear method doesn't work (does nothing)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Oct 6 07:16:50 EDT 2006


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 scostas at det.uvigo.es.

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

--- shadow/79595	2006-10-06 07:16:50.000000000 -0400
+++ shadow/79595.tmp.28548	2006-10-06 07:16:50.000000000 -0400
@@ -0,0 +1,98 @@
+Bug#: 79595
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Major
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: scostas at det.uvigo.es               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: The Form.Controls.Clear method doesn't work (does nothing)
+
+Description of Problem:
+
+The Form.Controls.Clear() method doesn't work. It should delete all the
+current widgets in the form, leaving it ready to put new widgets into it.
+
+
+Steps to reproduce the problem:
+
+I enclose a test code at the end of this error report, to show the problem.
+I tested it in Windows XP and Windows Mobile 5 and worked fine, but with
+libMono-winforms 1.1.17 (the current ones in Ubuntu Edgy) it works incorrectly.
+
+
+Actual Results:
+
+When the user clicks the first button, a new button is added to the form
+(which is rigth), but the old button remains there (which is wrong).
+
+
+Expected Results:
+
+The old button must be erased.
+
+
+How often does this happen? 
+
+Always
+
+
+Additional Information:
+
+Here is the sample code:
+
+using System;
+using System.Windows.Forms;
+
+public class principal:Form {
+
+	Button boton1;
+	Button boton2;
+
+	public principal() {
+
+		boton1 = new Button();
+		boton1.Text = "Click here";
+		boton1.Top = 10;
+		boton1.Click += new EventHandler(click1);
+		this.Controls.Add(boton1);
+	}
+	
+	public void click1(object sender, EventArgs e) {
+	
+		// here, the form should be cleared, erasing all the controls,
+		// but it didn't work. This is the bug
+		
+		this.Controls.Clear();
+		boton2 = new Button();
+		boton2.Text = "Exit test";
+		boton2.Top = 60; // put it lower to be sure that it won't overlap the old
+button
+		boton2.Click += new EventHandler(click2);
+		this.Controls.Add(boton2);
+	}
+	
+	public void click2(object sender, EventArgs e) {
+	
+		// exit the demo
+		
+		this.Close();
+	
+	}
+	
+	static public void Main() {
+	
+		principal classdemo = new principal();
+		Application.Run(classdemo);
+	
+	}
+	
+}


More information about the mono-bugs mailing list