Author: toshok
Date: 2006-08-08 18:54:16 -0400 (Tue, 08 Aug 2006)
New Revision: 63511
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
Log:
* DataGrid.cs: make BeginInit/EndInit actually do what they're
supposed to do - delay data binding until the EndInit call. Also,
make the table style collection's CollectionChangeAction.Refresh
work properly.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-08-08 22:36:45 UTC (rev 63510)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-08-08 22:54:16 UTC (rev 63511)
@@ -1,5 +1,10 @@
2006-08-08 Chris Toshok <[EMAIL PROTECTED]>
+ * DataGrid.cs: make BeginInit/EndInit actually do what they're
+ supposed to do - delay data binding until the EndInit call. Also,
+ make the table style collection's CollectionChangeAction.Refresh
+ work properly.
+
* GridTableStylesCollection.cs: raise a CollectionChangeEvent
(with action = Refresh) when a consituent table's MappingName is
changed.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-08-08 22:36:45 UTC (rev 63510)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-08-08 22:54:16 UTC (rev 63511)
@@ -239,7 +239,12 @@
CurrencyManager list_manager;
bool _readonly;
DataGridRow[] rows;
+
+ /* these fields make BeginInit/EndInit work */
bool initializing;
+ bool need_databinding;
+ object new_datasource;
+ string new_datamember;
/* column resize fields */
bool column_resize_active;
@@ -561,10 +566,16 @@
public string DataMember {
get { return datamember; }
set {
- if (SetDataMember (value)) {
- SetDataSource (datasource);
- SetNewDataSource ();
+ if (initializing) {
+ need_databinding = true;
+ new_datamember = value;
}
+ else {
+ if (SetDataMember (value)) {
+ SetDataSource (datasource);
+ SetNewDataSource ();
+ }
+ }
}
}
@@ -574,9 +585,15 @@
public object DataSource {
get { return datasource; }
set {
- SetDataMember ("");
- SetDataSource (value);
- SetNewDataSource ();
+ if (initializing) {
+ need_databinding = true;
+ new_datasource = value;
+ }
+ else {
+ SetDataMember ("");
+ SetDataSource (value);
+ SetNewDataSource ();
+ }
}
}
@@ -690,7 +707,7 @@
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected internal CurrencyManager ListManager {
get {
- if (BindingContext == null || datasource ==
null)
+ if (BindingContext == null || datasource ==
null)
return null;
if (list_manager != null)
@@ -1026,6 +1043,11 @@
public void EndInit ()
{
initializing = false;
+ if (need_databinding) {
+ SetDataMember (new_datamember);
+ SetDataSource (new_datasource);
+ SetNewDataSource ();
+ }
}
public void Expand (int row)
@@ -2266,17 +2288,22 @@
case CollectionChangeAction.Refresh: {
- if (e.Element != null && String.Compare
(list_name, ((DataGridTableStyle)e.Element).MappingName, true) == 0) {
- CurrentTableStyle =
(DataGridTableStyle)e.Element;
- ((DataGridTableStyle)
e.Element).CreateColumnsForTable (false);
- } else {
- CurrentTableStyle =
default_style;
-
current_style.GridColumnStyles.Clear ();
-
current_style.CreateColumnsForTable (false);
+ if (CurrentTableStyle == default_style
+ || String.Compare (list_name,
CurrentTableStyle.MappingName, true) != 0) {
+ DataGridTableStyle style =
styles_collection [list_name];
+ if (style != null) {
+ CurrentTableStyle =
style;
+
current_style.CreateColumnsForTable (false);
+ }
+ else {
+ CurrentTableStyle =
default_style;
+
current_style.GridColumnStyles.Clear ();
+
current_style.CreateColumnsForTable (false);
+ }
}
+
break;
-
}
}
CalcAreasAndInvalidate ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches