Author: pedro
Date: 2007-03-07 11:52:04 -0500 (Wed, 07 Mar 2007)
New Revision: 73893

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
Log:
2007-03-07  Pedro Mart?\195?\173nez Juli?\195?\161  <[EMAIL PROTECTED]>

        * DataGridView.cs: Change DataSource will clear column and row
        lists. Call Invalidate() to reflect DataSource change.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-07 16:44:22 UTC (rev 73892)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-07 16:52:04 UTC (rev 73893)
@@ -1,5 +1,10 @@
 2007-03-07  Pedro Martínez Juliá  <[EMAIL PROTECTED]>
 
+       * DataGridView.cs: Change DataSource will clear column and row
+       lists. Call Invalidate() to reflect DataSource change.
+
+2007-03-07  Pedro Martínez Juliá  <[EMAIL PROTECTED]>
+
        * DataGridView.cs: Add rows when DataSource is System.Data.DataView
        and a new row is added to it.
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs  
2007-03-07 16:44:22 UTC (rev 73892)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs  
2007-03-07 16:52:04 UTC (rev 73893)
@@ -589,29 +589,36 @@
                                         - the 
System.ComponentModel.IBindingList interface, such as the 
System.ComponentModel.Collections.BindingList<> class.
                                         - the 
System.ComponentModel.IBindingListView interface, such as the 
System.Windows.Forms.BindingSource class.
                                        */
-                                       if (!(value is IList) && !(value is 
IListSource) && !(value is IBindingList) && !(value is IBindingListView)) {
+                                       if (!(value == null || value is IList 
|| value is IListSource || value is IBindingList || value is IBindingListView)) 
{
                                                throw new 
NotSupportedException("Type cant be binded.");
                                        }
-                                       if (dataSource != null && dataSource is 
DataView) {
-                                               (dataSource as 
DataView).ListChanged -= OnListChanged;
+                                       if (dataSource != null) {
+                                               columns.Clear();
+                                               rows.Clear();
+                                               if (dataSource is DataView) {
+                                                       (dataSource as 
DataView).ListChanged -= OnListChanged;
+                                               }
                                        }
                                        dataSource = value;
                                        OnDataSourceChanged(EventArgs.Empty);
-                                       // DataBinding
-                                       if (value is IList) {
-                                               BindIList(value as IList);
+                                       if (dataSource != null) {
+                                               // DataBinding
+                                               if (value is IList) {
+                                                       BindIList(value as 
IList);
+                                               }
+                                               else if (value is IListSource) {
+                                                       BindIListSource(value 
as IListSource);
+                                               }
+                                               else if (value is IBindingList) 
{
+                                                       BindIBindingList(value 
as IBindingList);
+                                               }
+                                               else if (value is 
IBindingListView) {
+                                                       
BindIBindingListView(value as IBindingListView);
+                                                       //bool cosa = ((value 
as IBindingListView).SortDescriptions as IList).IsFixedSize;
+                                               }
+                                               OnDataBindingComplete(new 
DataGridViewBindingCompleteEventArgs(ListChangedType.Reset));
                                        }
-                                       else if (value is IListSource) {
-                                               BindIListSource(value as 
IListSource);
-                                       }
-                                       else if (value is IBindingList) {
-                                               BindIBindingList(value as 
IBindingList);
-                                       }
-                                       else if (value is IBindingListView) {
-                                               BindIBindingListView(value as 
IBindingListView);
-                                               //bool cosa = ((value as 
IBindingListView).SortDescriptions as IList).IsFixedSize;
-                                       }
-                                       OnDataBindingComplete(new 
DataGridViewBindingCompleteEventArgs(ListChangedType.Reset));
+                                       Invalidate();
                                }
                        }
                }

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

Reply via email to