diff options
author | Steven Boswell II <ulatekh@yahoo.com> | 2012-07-26 22:42:52 +0400 |
---|---|---|
committer | Thomas Goldstein <stifu@free.fr> | 2012-07-26 22:45:20 +0400 |
commit | 2f9c820c7ee1063d9fabcb2410b57843c17cb926 (patch) | |
tree | 64288714d6ea5ee590815488ca6db429df6e439c /mcs/class/Managed.Windows.Forms/Test | |
parent | f7549a72955d8611f40db7e8742843df195f0509 (diff) |
Properly update the combo box selected text when the current item is changed, and a part of the text is selected
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/Test')
-rw-r--r-- | mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs index cbd3c2bbf00..f7ccad8c399 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs @@ -1074,6 +1074,36 @@ namespace MonoTests.System.Windows.Forms Assert.AreEqual(false, eventFired, "SWC2"); } + [Test] + public void SelectionWithModification() + { + // ComboBox's this[int].set() was dealing with the + // current index badly. This reproduces the old bug and + // makes sure it's fixed. + ComboBox cb = new ComboBox (); + cb.DropDownStyle = ComboBoxStyle.DropDown; + + // Add a menu item. + string strItemText = "Item text"; + cb.Items.Add (strItemText); + + // Select the menu item. + cb.SelectedIndex = 0; + + // Move the selection to the end of the text. + cb.SelectionLength = 0; + cb.SelectionStart = strItemText.Length; + + // Now set the menu item's text to the empty string and + // back again. + cb.Items[0] = string.Empty; + cb.Items[0] = strItemText; + + // Make sure the text didn't get duplicated (i.e. the + // bugged code would produce "Item textItem text"). + Assert.AreEqual (strItemText, cb.Text, "A1"); + } + // Bug #333750 - DisplayMember assignation // when ComboBox already has a BindingContext BUT // handle hasn't been created yet. |