#endif
}
+ [Test]
+ public void PreferredHeight ()
+ {
+ // PreferredHeight is not tied to ItemHeight like we had it
+ ComboBox cb = new ComboBox ();
+
+ int h = cb.PreferredHeight;
+
+ cb.ItemHeight = 10;
+ Assert.AreEqual (h, cb.PreferredHeight, "A2");
+
+ cb.ItemHeight = 30;
+ Assert.AreEqual (h, cb.PreferredHeight, "A3");
+ }
+
#if NET_2_0
[Test]
public void ResetTextTest ()
Assert.AreEqual (-1, cmbbox.SelectedIndex, "#S3");
}
+ [Test] // bug 360862
+ public void SizeChangesAtCreateHandle ()
+ {
+ ComboBox cb = new ComboBox ();
+ cb.Font = new Font ("Arial", 24f);
+
+ int original = cb.Height;
+
+ IntPtr h = cb.Handle;
+
+ Assert.IsTrue (cb.Height > original, string.Format ("ComboBox height ({0}) should be bigger than original ({1})", cb.Height, original));
+ }
+
+ [Test]
+ public void Bug424270 ()
+ {
+ ComboBox cb = new ComboBox ();
+ cb.Items.Add ("ab");
+
+ cb.SelectedIndex = 0;
+
+ Assert.AreEqual (0, cb.SelectedIndex, "A1");
+ Assert.AreEqual ("ab", cb.SelectedItem, "A2");
+
+ cb.SelectedItem = null;
+
+ Assert.AreEqual (-1, cb.SelectedIndex, "A3");
+ Assert.AreEqual (null, cb.SelectedItem, "A4");
+ }
+
#if NET_2_0
[Test]
public void BehaviorAutoSize ()
gb.Location = new Point (5, 10);
f.Controls.Add (gb);
- Assert.AreEqual (new Rectangle (5, 10, 121, 21), gb.Bounds, "A1");
+ Assert.AreEqual (new Rectangle (5, 10, 121, gb.PreferredHeight), gb.Bounds, "A1");
gb.PublicScaleControl (new SizeF (2.0f, 2.0f), BoundsSpecified.All);
- Assert.AreEqual (new Rectangle (10, 20, 238, 21), gb.Bounds, "A2");
+ Assert.AreEqual (new Rectangle (10, 20, 238, gb.PreferredHeight), gb.Bounds, "A2");
gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Location);
- Assert.AreEqual (new Rectangle (5, 10, 238, 21), gb.Bounds, "A3");
+ Assert.AreEqual (new Rectangle (5, 10, 238, gb.PreferredHeight), gb.Bounds, "A3");
gb.PublicScaleControl (new SizeF (.5f, .5f), BoundsSpecified.Size);
- Assert.AreEqual (new Rectangle (5, 10, 121, 21), gb.Bounds, "A4");
- Console.WriteLine ("DONE");
+ Assert.AreEqual (new Rectangle (5, 10, 121, gb.PreferredHeight), gb.Bounds, "A4");
+
gb.PublicScaleControl (new SizeF (3.5f, 3.5f), BoundsSpecified.Size);
- Assert.AreEqual (new Rectangle (5, 10, 414, 21), gb.Bounds, "A5");
+ Assert.AreEqual (new Rectangle (5, 10, 414, gb.PreferredHeight), gb.Bounds, "A5");
gb.PublicScaleControl (new SizeF (2.5f, 2.5f), BoundsSpecified.Size);
- Assert.AreEqual (new Rectangle (5, 10, 1029, 21), gb.Bounds, "A6");
+ Assert.AreEqual (new Rectangle (5, 10, 1029, gb.PreferredHeight), gb.Bounds, "A6");
gb.PublicScaleControl (new SizeF (.2f, .2f), BoundsSpecified.Size);
- Assert.AreEqual (new Rectangle (5, 10, 209, 21), gb.Bounds, "A7");
+ Assert.AreEqual (new Rectangle (5, 10, 209, gb.PreferredHeight), gb.Bounds, "A7");
f.Dispose ();
}
}
}
#endif
+
+ private struct ComboVal
+ {
+ public string text;
+
+ public ComboVal (string t)
+ {
+ text = t;
+ }
+
+ public override string ToString ()
+ {
+ return text;
+ }
+ }
+
+ [Test]
+ public void SortTest ()
+ {
+ // Test sorting of objects with no IComparer
+ // should not crash
+
+ ComboBox cmb = new ComboBox ();
+ cmb.Items.Add (new ComboVal ("B"));
+ cmb.Items.Add (new ComboVal ("A"));
+ cmb.Sorted = true;
+ }
}
[TestFixture]
Assert.AreEqual (string.Empty, comboBox.SelectedText, "#I2");
}
+ [Test]
+ public void SortedSelectedItem ()
+ {
+ using (Form form = new Form ()) {
+ ComboBox box = new ComboBox ();
+ box.Sorted = true;
+
+ form.Controls.Add (box);
+ form.ShowInTaskbar = false;
+ form.Show ();
+
+ box.Items.Add ("English");
+ box.SelectedItem = "English";
+
+ box.Items.Add ("Danish");
+ Assert.AreEqual ("English", box.SelectedItem, "A1");
+
+ box.Items.Add ("French");
+ Assert.AreEqual ("English", box.SelectedItem, "A2");
+
+ box.Items.Add ("Brazilian Portuguese");
+ box.Items.Add ("Arabic");
+ Assert.AreEqual ("English", box.SelectedItem, "A3");
+ }
+ }
+
public class Person
{
private readonly string _name;
}
}
}
-}
+}
\ No newline at end of file