Hi, in my winform app i have several UltraComboEditor and whenever a user select a different item the UI get irresponsive because the UltraComboEditors retains focus and prevent other controls to get focused. This only happens when the user select a different item, if users click the same current item everithing is ok.
I have the UltraComboEditor bound to bindingsource controls which have the datasource as collections of bussines objects loaded from db, in those BO i overrided the ToString() property and that is the text displayed in the UltraComboEditors, no DisplayMember/ValueMember used here, those UltraComboEditors are binded to a properties which reference entities.
Thanks for your help.
Elio
Hi Elio,
Are you binding any properties of the control, like Value, in addition to binding the list? One reason this might be happening is if the ValueMember of the combo does not match the data type the value is bound to. The underlying data source might be raising an exception because of mismatched data types which the BindingManager is catching.
Another thing to check is the LimitToList property. Has that been set to true?
Are you handling the Validating event of the control and cancelling that?
Hi Mike, this is what i have in .designer file ppart of this--------------EmployeeView.designer.cs----------------//dptoUltraComboEditorthis.dptoUltraComboEditor.AutoComplete = true;this.dptoUltraComboEditor.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.employeeBindingSource, "Department", true));this.dptoUltraComboEditor.DataSource = this.departmentsBindingSource;this.dptoUltraComboEditor.DisplayMember = "Name";this.dptoUltraComboEditor.DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList;this.dptoUltraComboEditor.SyncWithCurrencyManager = false;
//departmentsBindingSourcethis.departmentsBindingSource.DataSource = typeof(CDC.Core.Domain.Department)------------------------------------------------------------------------
------------EmployeeView.cs----------------------------------departmentsBindingSource.DataSource=departemts //departemts is a List<Department> loaded from db-------------------------------------------------------------------------*Another thing to check is the LimitToList property. Has that been set to true? ->Nop*Are you handling the Validating event of the control and cancelling that? ->NopThanks for your time Mike
Solved, for those that are struggling (or will) with the same issue, this is the solution:The problem was that since i was not setting the ValueMember property the value retrieved by the bindings from the UltraCombo was the text displayed in the UltraCombo, thus i get an Invalid cast exception while behind the scene the binding api was trying to cast from String to Department, the fix was to include a property, which i named "This", in the referenced class that return the current instance and set the ValueMember of the UltraCombo to that property:
Having the following class:public class Employee{ private Department _department; public Deparment Deparment //<-- A reference to Department { get{return _department;} set{ _department= value;} }}Notice the Departmet propety which is a reference to the following class:public class Deparment{ private string _name; public string Name { get{return _name;} set{ _name= value;} }
public Deparment This //<-- I have to add this property to be used in ValueMember property from the UltraComboEditor{get { return this; }}}
The following are the relevant lines regard to my UltraComboEditor placed in View.designer.csthis.departmentUltraComboEditor.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.employeeBindingSource, "Department", true));this.deparmentUltraComboEditor.DataSource = this.deparmentsBindingSource;this.deparmentUltraComboEditor.ValueMember = "This"; //<--Notice the ValueMember property setted to "This"Thanks Mike, you shedd the light on this with your comment.The fix was based on an old post from Bart Mermuys:http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic36727.aspx