[Mono-bugs] [Bug 79077][Nor] Changed - ListBox: Setting SelectedItem to null doesn't match MS behaviour
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Aug 15 19:57:26 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 unserkonig at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79077
--- shadow/79077 2006-08-15 11:15:28.000000000 -0400
+++ shadow/79077.tmp.5268 2006-08-15 19:57:26.000000000 -0400
@@ -30,6 +30,52 @@
------- Additional Comments From peter at novonyx.com 2006-08-15 10:39 -------
->Mike
------- Additional Comments From mkestner at ximian.com 2006-08-15 11:15 -------
Were you attaching a sample?
+
+------- Additional Comments From unserkonig at gmail.com 2006-08-15 19:57 -------
+// Sample
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+
+public class TestForm : Form
+{
+ static void Main ()
+ {
+ Application.Run (new TestForm ());
+ }
+
+ ListBox lb;
+
+ public TestForm ()
+ {
+ lb = new ListBox ();
+ lb.Location = new Point (5, 5);
+ lb.Items.AddRange (new object [] {"One", "Two"});
+ lb.Parent = this;
+ lb.SelectedIndexChanged += new EventHandler (OnSelectedIndexChanged);
+
+ Button button = new Button ();
+ button.Location = new Point (5, lb.Bottom + 5);
+ button.Size = new Size (100, 30);
+ button.Text = "Set SelectedItem";
+ button.Parent = this;
+ button.Click += new EventHandler (OnClick);
+ }
+
+ void OnClick (object o, EventArgs args)
+ {
+ lb.SelectedItem = null; // Should unselect items
+ }
+
+ void OnSelectedIndexChanged (object o, EventArgs args)
+ {
+ // Print info about the state of ListBox (SelectedIndex & SelectedItem)
+ Console.WriteLine ("Selected Item = " + (lb.SelectedItem == null ?
+"null" : lb.SelectedItem.ToString ()) +
+ "\nSelected Index = " + lb.SelectedIndex + "\n");
+ }
+}
+
More information about the mono-bugs
mailing list