I have a BeforeDropDown Event for Ultracombo, where I load the data and bind to the UltraCombo
The problem is that the current value displayed disappears.
here is a small winforms test program I created
private DataTable datatable; public Form1() { InitializeComponent(); this.ultraCombo1.Text = "1"; this.ultraCombo1.BeforeDropDown += new CancelEventHandler(ultraCombo1_BeforeDropDown); } void ultraCombo1_BeforeDropDown(object sender, CancelEventArgs e) { datatable = new DataTable("COMPMS0"); datatable.Columns.Add("Company", typeof(int)); datatable.Columns.Add("Company description", typeof(string)); datatable.Rows.Add("9", "Nine"); datatable.Rows.Add("17", "Seventeen"); datatable.Rows.Add("1", "ZZZZ"); datatable.Rows.Add("3", "Three"); this.ultraCombo1.DataSource = datatable; }
help is appreciated
I created AfterDropDown event handler
In my BeforeDropDown, I saved the current value to global varialble
and than in my AfterDropDown I set the text to that global and it works
Is this a required hack? anything better?
appreciate any input
My guess is that your DropDownStyle is set to DropDownList. In that case, the Combo will only accept a value that exists on the list. So if you change the DataSource, the list gets cleared and re-populated. If the current value of the control exists on the new list, then the Combo should be maintaining the value. If it does not, then the value should be cleared - since the original value is no longer valid.