2009-10-23 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Fri, 23 Oct 2009 01:54:39 +0000 (01:54 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Fri, 23 Oct 2009 01:54:39 +0000 (01:54 -0000)
* ColumnHeader.cs: When calculating the width and height of the
column, try to expand to the right and use all the free space if we
are the last column *and* the resize mode is set to -2/header content.
Fixes #544716.

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

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

index fb9e73e7a4450eed5c3d8dddee3cf7f9b3ac9ba1..88f1e6b9457ce55e4341f3adf236f8bd6ec40122 100644 (file)
@@ -1,3 +1,10 @@
+2009-10-23  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * ColumnHeader.cs: When calculating the width and height of the
+       column, try to expand to the right and use all the free space if we
+       are the last column *and* the resize mode is set to -2/header content.
+       Fixes #544716.
+
 2009-10-14  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListView.cs: When retrieving the top item, take into account the
index cac8972e0b665f41f2973af6edb912b6ed18a143..ee3ccfd0b431a88519913cff901b5d0af2f6574a 100644 (file)
@@ -156,13 +156,27 @@ namespace System.Windows.Forms
                        else
                                column_rect.Height = ThemeEngine.Current.ListViewGetHeaderHeight (null, ThemeEngine.Current.DefaultFont);
 
-                       if (width >= 0)
+                       column_rect.Width = 0;
+
+                       if (width >= 0) // manual width
                                column_rect.Width = width;
-                       else if (Index != -1) {
+                       else if (Index != -1) { // automatic width, either -1 or -2
+                               // try to expand if we are the last column
+                               bool expand_to_right = Index == owner.Columns.Count - 1 && width == -2;
+                               Rectangle visible_area = owner.ClientRectangle;
+
                                column_rect.Width = owner.GetChildColumnSize (Index).Width;
                                width = column_rect.Width;
-                       } else
-                               column_rect.Width = 0;
+
+                               // expand only if we have free space to the right
+                               if (expand_to_right && column_rect.X + column_rect.Width < visible_area.Width) {
+                                       width = visible_area.Width - column_rect.X;
+                                       if (owner.v_scroll.Visible)
+                                               width -= owner.v_scroll.Width;
+
+                                       column_rect.Width = width;
+                               }
+                       }
                }
 
                internal void SetListView (ListView list_view)