RexHeadlong
Programmer
Does anybody have an idea why, when I assign a ComboBox.Text property, it does not appear to take?
I have a ComboBox with DropDownStyle = DropDown.
During the Load event handler of my form, I bind it to an ArrayList of strings.
But, I want the initial text in the ComboBox to be a string that is not in the ArrayList. So, I assign ComboBox.Text. But, I never see this text in the ComboBox and instead I see the text of the first string in the ArrayList.
Here is the code inside my form's Load handler:
In the debugger, I look at the properties just before the load event ends, and the .Text property is "no item", and the .SelectedIndex property is -1. Great. But, when the form appears on screen, what I see is "item 1" in the text area as if it were the selected item.
I put breakpoints in TextChanged and SelectedIndexChanged event handlers to see if there is some outside force changing the text or the selected item, but these do not get fired after my load event.
Can anybody shed some light on this? Thanks in advance for any help!
I have a ComboBox with DropDownStyle = DropDown.
During the Load event handler of my form, I bind it to an ArrayList of strings.
But, I want the initial text in the ComboBox to be a string that is not in the ArrayList. So, I assign ComboBox.Text. But, I never see this text in the ComboBox and instead I see the text of the first string in the ArrayList.
Here is the code inside my form's Load handler:
Code:
this.cmBoxFormula.BeginUpdate();
ArrayList itemArray = new ArrayList(3);
itemArray.Add("item 1");
itemArray.Add("item 2");
itemArray.Add("item 3");
this.cmBoxFormula.DataSource = itemArray;
this.cmBoxFormula.SelectedIndex = -1;
this.cmBoxFormula.Text = "no item";
this.cmBoxFormula.EndUpdate();
In the debugger, I look at the properties just before the load event ends, and the .Text property is "no item", and the .SelectedIndex property is -1. Great. But, when the form appears on screen, what I see is "item 1" in the text area as if it were the selected item.
I put breakpoints in TextChanged and SelectedIndexChanged event handlers to see if there is some outside force changing the text or the selected item, but these do not get fired after my load event.
Can anybody shed some light on this? Thanks in advance for any help!