I am having a problem with an ultracombo losing the ultracombo.value under the following circumstance - code and comments below. The code is VB
' Problem with ultracombo DropDownStyle = DropDownList - losing ultracombo.value
' Design Time settings for ultracombobox - cboPatientProviderList Me.cboPatientProviderList.DataBindings.Add(New System.Windows.Forms.Binding("Value", _ Me.PatientBindingSource, "fk_pers_prov_ProviderKey", True)) Me.cboPatientProviderList.DataSource = Me.ProviderListBindingSource Me.cboPatientProviderList.DisplayMember = "prov_LastName" Me.cboPatientProviderList.ValueMember = "pk_prov_ProviderKey" Me.cboPatientProviderList.DropDownStyle = _ Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList
Me.ProviderListBindingSource.DataMember = "ProviderList" Me.ProviderListBindingSource.DataSource = Me.ProviderDataSet
' Form Load Me.ProviderDataSet.ProviderList.Clear() Me.ProviderListTableAdapter.Fill(Me.ProviderDataSet.ProviderList)' At this point cboPatientProviderList binds and populates just fine' cbo.PatientProviderList.value = nnn from the fk_pers_prov_ProviderKey through the DataBinding above
' At any time the user may request that the cbo.PatientProviderList DataSource be refreshed in which case the following code is invoked Me.ProviderDataSet.ProviderList.Clear() Me.ProviderListTableAdapter.Fill(Me.ProviderDataSet.ProviderList)' The datasource refreshes, the cboPatientProviderList rebinds and shows any updates, however the' cbo.PatientProviderList.value = Nothing - Has it lost the fk_pers_prov_ProviderKey DataBinding ' even though nothing was done to the PatientBindingSource?
' However if at design time the DropDownStyle = DrowDown (not DropDownList) ' then cbo.PatientProviderList.value is not lost when the cbo.PatientProviderList DataSource is refreshed
Mike,
Thanks for taking the time for the explanation, it was just not the behavior I wanted. Since there are two data sources involved and I only reset the data source for the drop down, I hoped that the combo would still be bound to the DataBinding data source. In fact I find that if I reset that data source then the combo.value comes back. The down side of that was if there had been a change in the combo.value that had not yet been saved to that DataBinding data source, that change is lost. Anyway thanks again, I have used the DropDownStyle = DropDown with the LimitToList property to get approximately the result I want. Thanks again.
If the Combo is in DropDownList style, then it cannot accept any value that is not on the list. So if you reset the data source, there will be a time when there are no items on the list - therefore the Combo will lose it's value.
In DropDown style, this doesn't happen, because the combo can accept a value that is not on the list, so it maintains the value when all the items are cleared.