Author: toshok
Date: 2006-12-17 12:04:53 -0500 (Sun, 17 Dec 2006)
New Revision: 69606

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
Log:
2006-12-17  Chris Toshok  <[EMAIL PROTECTED]>

        * DataGrid.cs: hook up MetaDataChanged event on the list manager,
        and rebind our columns when it does - this way, if you make
        changes to the DataTable (or set the Table attribute on a DataView
        after setting it as the DataGrid's DataSource, the changes are
        made visible.)  Fixes bug #80107.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-12-17 17:03:36 UTC (rev 69605)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-12-17 17:04:53 UTC (rev 69606)
@@ -1,3 +1,11 @@
+2006-12-17  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * DataGrid.cs: hook up MetaDataChanged event on the list manager,
+       and rebind our columns when it does - this way, if you make
+       changes to the DataTable (or set the Table attribute on a DataView
+       after setting it as the DataGrid's DataSource, the changes are
+       made visible.)  Fixes bug #80107.
+
 2006-12-17  Daniel Nauck  <[EMAIL PROTECTED]>
 
        * ListViewGroup.cs: add internal Location property for layouting.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs      
2006-12-17 17:03:36 UTC (rev 69605)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs      
2006-12-17 17:04:53 UTC (rev 69606)
@@ -1440,7 +1440,6 @@
                                DataGridCell new_cell = new DataGridCell 
(testinfo.Row, testinfo.Column);
 
                                if ((new_cell.Equals (current_cell) == false) 
|| (!is_editing)) {
-                                       EnsureCellVisibility (new_cell);
                                        CurrentCell = new_cell;
                                        Edit ();
                                } else {
@@ -2165,12 +2164,14 @@
                
                private void ConnectListManagerEvents ()
                {
+                       list_manager.MetaDataChanged += new EventHandler 
(OnListManagerMetaDataChanged);
                        list_manager.PositionChanged += new EventHandler 
(OnListManagerPositionChanged);
                        list_manager.ItemChanged += new ItemChangedEventHandler 
(OnListManagerItemChanged);
                }
                
                private void DisconnectListManagerEvents ()
                {
+                       list_manager.MetaDataChanged -= new EventHandler 
(OnListManagerMetaDataChanged);
                        list_manager.PositionChanged -= new EventHandler 
(OnListManagerPositionChanged);
                        list_manager.ItemChanged -= new ItemChangedEventHandler 
(OnListManagerItemChanged);
                }
@@ -2307,23 +2308,7 @@
                        if (list_manager != null)
                                ConnectListManagerEvents ();
 
-                       if (list_manager != null) {
-                               string list_name = list_manager.GetListName 
(null);
-                               if (TableStyles[list_name] == null) {
-                                       current_style.GridColumnStyles.Clear 
();                        
-                                       current_style.CreateColumnsForTable 
(false);
-                               }
-                               else if (CurrentTableStyle.MappingName != 
list_name) {
-                                       // If the style has been defined by the 
user, use it
-                                       CurrentTableStyle = 
styles_collection[list_name];
-                                       current_style.CreateColumnsForTable 
(true);
-                               }
-                               else {
-                                       current_style.CreateColumnsForTable 
(true);
-                               }
-                       }
-                       else
-                               current_style.CreateColumnsForTable (false);
+                       BindColumns ();
 
                        if (old_lm != list_manager) {
                                /* reset first_visiblerow to 0 here before
@@ -2344,13 +2329,6 @@
                        OnDataSourceChanged (EventArgs.Empty);
                }
 
-               private void OnListManagerPositionChanged (object sender, 
EventArgs e)
-               {
-                       from_positionchanged_handler = true;
-                       CurrentRow = list_manager.Position;
-                       from_positionchanged_handler = false;
-               }
-
                void RecreateDataGridRows (bool recalc)
                {
                        DataGridRelationshipRow[] new_rows = new 
DataGridRelationshipRow[RowsCount + (ShowEditRow ? 1 : 0)];
@@ -2386,6 +2364,39 @@
                        CalcAreasAndInvalidate ();
                }
 
+               void BindColumns ()
+               {
+                       if (list_manager != null) {
+                               string list_name = list_manager.GetListName 
(null);
+                               if (TableStyles[list_name] == null) {
+                                       current_style.GridColumnStyles.Clear 
();                        
+                                       current_style.CreateColumnsForTable 
(false);
+                               }
+                               else if (CurrentTableStyle.MappingName != 
list_name) {
+                                       // If the style has been defined by the 
user, use it
+                                       CurrentTableStyle = 
styles_collection[list_name];
+                                       current_style.CreateColumnsForTable 
(true);
+                               }
+                               else {
+                                       current_style.CreateColumnsForTable 
(true);
+                               }
+                       }
+                       else
+                               current_style.CreateColumnsForTable (false);
+               }
+
+               private void OnListManagerMetaDataChanged (object sender, 
EventArgs e)
+               {
+                       BindColumns ();
+               }
+
+               private void OnListManagerPositionChanged (object sender, 
EventArgs e)
+               {
+                       from_positionchanged_handler = true;
+                       CurrentRow = list_manager.Position;
+                       from_positionchanged_handler = false;
+               }
+
                private void OnListManagerItemChanged (object sender, 
ItemChangedEventArgs e)
                {
                        if (e.Index == -1) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to