* ListBox.cs: If the items are cleared with Items.Clear set
authorAlexander Olk <aolk@mono-cvs.ximian.com>
Sat, 2 Sep 2006 10:43:03 +0000 (10:43 -0000)
committerAlexander Olk <aolk@mono-cvs.ximian.com>
Sat, 2 Sep 2006 10:43:03 +0000 (10:43 -0000)
  top_index to 0.

svn path=/trunk/mcs/; revision=64764

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs

index 60d49aa790dff064bfbbfe8ee91e787c64bbfa90..e12bd8f53e4ba5913fa38d8e952372f260bf1fdc 100644 (file)
@@ -1,8 +1,7 @@
 2006-09-02  Alexander Olk  <alex.olk@googlemail.com>
 
-       * ListBox.cs: Don't unselect an item if the selection ArrayList
-         is empty. This prevents a crash when the collection was cleared
-         before calling SelectedIndex.
+       * ListBox.cs: If the items are cleared with Items.Clear set
+         top_index to 0.
 
 2006-09-01  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
index 7c3e9d4e546c6ae15b1d9482c72938e368936085..90c0e758c108d810fb73a174f6e824317fce98dc 100644 (file)
@@ -1737,9 +1737,6 @@ namespace System.Windows.Forms
                // Removes an item in the Selection array and marks it visually as unselected
                private void UnSelectItem (int index, bool remove)
                {
-                       if (selection.Count == 0)
-                               return;
-
                        if (index == -1)
                                return;
 
@@ -1769,17 +1766,18 @@ namespace System.Windows.Forms
                internal virtual void CollectionChanged ()
                {
                        if (sorted) 
-                               Sort ();                                
-
-                       if (!IsHandleCreated || suspend_layout)
-                               return;
-
-                       Layout ();
-
+                               Sort ();
+                       
                        if (Items.Count == 0) {
                                selected_index = -1;
                                focused_item = -1;
+                               top_index = 0;
                        }
+                       
+                       if (!IsHandleCreated || suspend_layout)
+                               return;
+
+                       Layout ();
 
                        base.Refresh ();
                }