c# - ComboBox.DropDownHeight values doesn't change when adding or removing items -
when running following code in wfa
public partial class form1 : form { string[] items = { "a", "b", "c", "d", "e" }; public form1() { initializecomponent(); updatedropdownheight(); } private void updatedropdownheight() { textbox1.text = combobox1.dropdownheight.tostring(); } private void button_populate_click(object sender, eventargs e) { for(int = 0; i<items.length; i++) { combobox1.items.add(items[i]); } updatedropdownheight(); } private void button_clear_click(object sender, eventargs e) { combobox1.items.clear(); updatedropdownheight(); } }
i have noticed combobox1.dropdownheight
value never changes when new items added combo box. apparent drop down area changes when button_populate
clicked through.
users question
provides perplexing answer on how resize apparent drop down area after removing items. purpose of dropdownheight
property , changing apparent drop down area of combobox
?
also not sure problem you're trying solve, if you're trying adjust height of dropdownheight, can achieved below.
private void updatedropdownheight() { int dropdownheight = 0; (int = 0; <= combobox1.items.count; i++) { dropdownheight = dropdownheight + (combobox1.itemheight); } combobox1.dropdownheight = dropdownheight; textbox1.text = combobox1.dropdownheight.tostring(); }
Comments
Post a Comment