2009-01-03 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sun, 4 Jan 2009 02:54:18 +0000 (02:54 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sun, 4 Jan 2009 02:54:18 +0000 (02:54 -0000)
* BindingNavigator.cs: Properly enable/disable the toolstrip buttons,
based on whether the binding source is availble or not. Fixes #463008.

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

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

index 07a99e8811752d6de29d133af8f2682ae325cca4..b3877e8f73a1e99ce40e5fa4c536de7956b2467b 100644 (file)
@@ -316,36 +316,36 @@ namespace System.Windows.Forms
                {
                        try
                        {
-                               bool isNull = (bindingSource == null);
+                               bool is_source_available = bindingSource != null;
                                initFlag = true;
                                //changingText = true;
 
                                if (addNewItem != null)
-                                       addNewItem.Enabled = isNull ? addNewItem.Enabled : this.bindingSource.AllowNew;
+                                       addNewItem.Enabled = is_source_available && bindingSource.AllowNew;
 
                                if (moveFirstItem != null)
-                                       moveFirstItem.Enabled = isNull ? moveFirstItem.Enabled : bindingSource.Position > 0;
+                                       moveFirstItem.Enabled = is_source_available && bindingSource.Position > 0;
 
                                if (moveLastItem != null)
-                                       moveLastItem.Enabled = isNull ? moveLastItem.Enabled : bindingSource.Position < (bindingSource.Count - 1);
+                                       moveLastItem.Enabled = is_source_available && bindingSource.Position < (bindingSource.Count - 1);
 
                                if (moveNextItem != null)
-                                       moveNextItem.Enabled = isNull ? moveNextItem.Enabled : bindingSource.Position < (bindingSource.Count - 1);
+                                       moveNextItem.Enabled = is_source_available && bindingSource.Position < (bindingSource.Count - 1);
 
                                if (movePreviousItem != null)
-                                       movePreviousItem.Enabled = isNull ? movePreviousItem.Enabled : bindingSource.Position > 0;
+                                       movePreviousItem.Enabled = is_source_available && bindingSource.Position > 0;
 
                                if (deleteItem != null)
-                                       deleteItem.Enabled = isNull ? deleteItem.Enabled : (bindingSource.Count != 0 && bindingSource.AllowRemove);
+                                       deleteItem.Enabled = is_source_available && (bindingSource.Count != 0 && bindingSource.AllowRemove);
 
                                if (countItem != null) {
-                                       countItem.Text = string.Format(countItemFormat, isNull ? 0 : bindingSource.Count);
-                                       countItem.Enabled = !isNull && bindingSource.Count > 0;
+                                       countItem.Text = string.Format(countItemFormat, is_source_available ? bindingSource.Count : 0);
+                                       countItem.Enabled = is_source_available && bindingSource.Count > 0;
                                }
 
                                if (positionItem != null) {
-                                       positionItem.Text = string.Format("{0}", isNull ? 0 : bindingSource.Position + 1);
-                                       positionItem.Enabled = !isNull && bindingSource.Count > 0;
+                                       positionItem.Text = string.Format("{0}", is_source_available? bindingSource.Position + 1 : 0);
+                                       positionItem.Enabled = is_source_available && bindingSource.Count > 0;
                                }
                        }
                        finally
index 21cafc145363148b88a3c6d29b57a886a99881dc..ea099517919fbb3bc12e2e59cd8fe8b781d74ca1 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-03  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * BindingNavigator.cs: Properly enable/disable the toolstrip buttons,
+       based on whether the binding source is availble or not. Fixes #463008.
+
 2009-01-03  Ivan N. Zlatev  <contact@i-nz.net>
 
        * DataGridViewCell.cs: We should return a value even if we are not bound