2007-08-10 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Fri, 10 Aug 2007 17:27:33 +0000 (17:27 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Fri, 10 Aug 2007 17:27:33 +0000 (17:27 -0000)
* TextBoxBase.cs: Fix SelectionLength when no text selected to match MS:
1.1 2.0
Handle Not Created -1 0
Handle Created 0 0
[Fixes bug #82371]

2007-08-10  Jonathan Pobst  <monkey@jpobst.com>

* TextBoxTest.cs: New test for 82371 to illustrate SelectionLength value when
no text is selected.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs

index 8ec74269b36a95ea2da99566b1695f39cf700708..31a4787058df16dab9faa1b82b409a7ee3767466 100644 (file)
@@ -1,3 +1,11 @@
+2007-08-10  Jonathan Pobst  <monkey@jpobst.com>
+
+       * TextBoxBase.cs: Fix SelectionLength when no text selected to match MS:
+                                       1.1             2.0
+       Handle Not Created      -1              0
+       Handle Created          0               0
+       [Fixes bug #82371]
+
 2007-08-10  Jonathan Pobst  <monkey@jpobst.com>
 
        * ToolTip.cs: Hide the tooltip if the control is clicked to match MS behavior.
index 46a1188ba5af360f389931b864f19d061347dc65..73cd71e72725e792292502b5c265a5e8734f2938 100644 (file)
@@ -537,8 +537,12 @@ namespace System.Windows.Forms {
                public virtual int SelectionLength {
                        get {
                                int res = document.SelectionLength ();
-                               if (res == 0)
+
+#if !NET_2_0
+                               if (res == 0 && !IsHandleCreated)
                                        res = -1;
+#endif
+
                                return res;
                        }
 
index 7545f18a1fd75da9feb239253be2472bc55047e6..2dcadaf2ebb88d1e81e73c01faa91a92c4357e93 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-10  Jonathan Pobst  <monkey@jpobst.com>
+
+       * TextBoxTest.cs: New test for 82371 to illustrate SelectionLength value when
+       no text is selected.
+
 2007-08-09  Jonathan Pobst  <monkey@jpobst.com>
 
        * ListBoxTest.cs: Mark test MethodScaleControl as not working.
index d6a49eaa7cb12d3e40128f286aa17f022ffffebc..dfc418b05dd5ee9814df83feec5c77e457ea9727 100644 (file)
@@ -673,6 +673,26 @@ namespace MonoTests.System.Windows.Forms
                        form.Close ();
                }
 
+               [Test]  // bug 82371
+               public void PropertySelectionLength ()
+               {
+                       TextBox tb = new TextBox ();
+                       RichTextBox rtb = new RichTextBox ();
+                       
+#if NET_2_0
+                       Assert.AreEqual (0, tb.SelectionLength, "A1-NET20");
+                       Assert.AreEqual (0, rtb.SelectionLength, "A2-NET20");
+#else
+                       Assert.AreEqual (-1, tb.SelectionLength, "A1-NET11");
+                       Assert.AreEqual (-1, rtb.SelectionLength, "A2-NET11");
+#endif
+
+                       IntPtr i = tb.Handle;
+                       i = rtb.Handle;
+
+                       Assert.AreEqual (0, tb.SelectionLength, "A3");
+                       Assert.AreEqual (0, rtb.SelectionLength, "A4");
+               }
                
                [Test]
                public void ModifiedTest ()