* System.Windows.Forms/DataGridViewColumn.cs: Throw if the SortMode
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Thu, 9 Aug 2007 08:43:05 +0000 (08:43 -0000)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Thu, 9 Aug 2007 08:43:05 +0000 (08:43 -0000)
  conflicts with DataGridView's SelectionMode.
* Test/System.Windows.Forms/DataGridViewColumnCollectionTest.cs: Added
  AddFullColumnSelect.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumn.cs
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewColumnCollectionTest.cs

index abd75a9425f2a580b9cc3051619cc546445d76d4..3ef04b420b8831fcfe97f69b32982924f8dee5c0 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-09  Rolf Bjarne Kvinge <RKvinge@novell.com> 
+
+       * DataGridViewColumn.cs: Throw if the SortMode conflicts with DataGridView's
+         SelectionMode.
+
 2007-08-08  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListView.cs: In ListViewItemsCollection check that owner is
index 39828220c029fcab31d108032e16c87ccec37313..fa10e312878a93cf40cd0d703730ef8557e72dc3 100644 (file)
@@ -353,7 +353,9 @@ Example */
                public DataGridViewColumnSortMode SortMode {
                        get { return sortMode; }
                        set {
-                               // System.InvalidOperationException: The value assigned to the property conflicts with System.Windows.Forms.DataGridView.SelectionMode.
+                               if (value == DataGridViewColumnSortMode.Automatic && DataGridView != null && DataGridView.SelectionMode == DataGridViewSelectionMode.FullColumnSelect)
+                                       throw new InvalidOperationException ("Column's SortMode cannot be set to Automatic while the DataGridView control's SelectionMode is set to FullColumnSelect.");
+
                                if (sortMode != value) {
                                        sortMode = value;
                                        if (DataGridView != null) {
@@ -451,7 +453,11 @@ Example */
                }
 
                internal override void SetDataGridView (DataGridView dataGridView) {
-                       base.SetDataGridView(dataGridView);
+                       if (sortMode == DataGridViewColumnSortMode.Automatic && dataGridView != null && dataGridView.SelectionMode == DataGridViewSelectionMode.FullColumnSelect) {
+                               throw new InvalidOperationException ("Column's SortMode cannot be set to Automatic while the DataGridView control's SelectionMode is set to FullColumnSelect.");
+                       }
+                       
+                       base.SetDataGridView (dataGridView);
                        if (cellTemplate != null) {
                                cellTemplate.SetDataGridView(dataGridView);
                        }
index 617c68001b36ee1672c963665d1db49aee6c720a..37dc8e48cec8772810ec4bf9caa6b47b0a4f5bb2 100644 (file)
@@ -1,3 +1,7 @@
+2007-08-09  Rolf Bjarne Kvinge <RKvinge@novell.com> 
+
+       * DataGridViewColumnCollectionTest.cs: Added AddFullColumnSelect.
+
 2007-08-08  Rolf Bjarne Kvinge <RKvinge@novell.com> 
 
        * ContainerControlTest.cs, ControlTest.cs, DefaultLayoutTest.cs,
index ab92be2dd01e40d5a3888c9a14bcbc9888ede8ad..6196ec2096a487592708971606f5ab79e097a445 100644 (file)
@@ -38,6 +38,15 @@ namespace MonoTests.System.Windows.Forms
        [TestFixture]\r
        public class DataGridViewColumnCollectionTest \r
        {\r
+               [Test]\r
+               [ExpectedException (typeof (InvalidOperationException), "Column's SortMode cannot be set to Automatic while the DataGridView control's SelectionMode is set to FullColumnSelect.")]\r
+               public void AddFullColumnSelect ()\r
+               {\r
+                       DataGridView dgv = new DataGridView ();\r
+                       dgv.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;\r
+                       dgv.Columns.Add ("A", "A");\r
+               }\r
+               \r
                [Test]\r
                public void Add ()\r
                {\r