2008-05-08 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Thu, 8 May 2008 20:33:35 +0000 (20:33 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Thu, 8 May 2008 20:33:35 +0000 (20:33 -0000)
* ListBox.cs: Various fixes for MultiColumn listboxen.
[Fixes bug #388114]

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

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

index 82aab88ef79ae5ae81a11c6ae3e969ea30ce1fb5..7d2c1a84863981b2bf55553ad54bd210437b33b9 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-08  Jonathan Pobst  <monkey@jpobst.com>
+
+       * ListBox.cs: Various fixes for MultiColumn listboxen.
+       [Fixes bug #388114]
+
 2008-05-08  Andreia Gaita <avidigal@novell.com> 
 
        * HtmlElement.cs: Implement Style property
index ab01b198b993a4b809ae24e8b64529783313fd37..324682d09f3b7df864f806a5c275f972b9fe2233 100644 (file)
@@ -434,6 +434,7 @@ namespace System.Windows.Forms
                                        
                                multicolumn = value;
                                LayoutListBox ();
+                               Invalidate ();
                        }
                }
 
@@ -1450,6 +1451,11 @@ namespace System.Windows.Forms
                                if (SelectedIndex == Items.Count - 1)
                                        return -1;
 
+                               if (multicolumn) {
+                                       selected_index = SelectedIndex + 1;
+                                       break;
+                               }
+                               
                                int bottom = 0;
                                ArrayList heights = new ArrayList ();
                                if (draw_mode == DrawMode.OwnerDrawVariable) {
@@ -2013,13 +2019,24 @@ namespace System.Windows.Forms
                        if (index < top_index) {
                                top_index = index;
                                UpdateTopItem ();
-                       } else {
+                       } else if (!multicolumn) {
                                int rows = items_area.Height / ItemHeight;
                                if (index >= (top_index + rows))
                                {
                                        top_index = index - rows + 1;
                                        UpdateTopItem ();
                                }
+                       } else {
+                               int rows = items_area.Height / ItemHeight;
+                               int cols = items_area.Width / ColumnWidthInternal;
+                               
+                               if (index >= (top_index + (rows * cols))) {
+                                       int incolumn = ((index + 1) / rows);
+                                       top_index = (incolumn - (cols - 1)) * rows;
+
+                                       UpdateTopItem ();
+                                       Invalidate ();
+                               }
                        }
                }