Hi there,
I'm having issues when changing the DataSource of a UltraComboEditor, databound using the DisplayMember/ValueMember/Value property.
Whether I change the DataSource before the source property or after, the UltraComboEditor always shows no selection after the change (even though the backing object property has been changed and matches an item in the DataSource by ValueMember) and it *looks* like something went wrong and the user has to select from the combo editor again.
How should DataSources for UltraComboEditors be limited in code?
Attached is a small (complete) WinForms app that shows this behavior.
using System;
using System.Diagnostics;
using System.Windows.Forms;
using Infragistics.Win;
using Infragistics.Win.Misc;
using Infragistics.Win.UltraWinEditors;
namespace UltraComboTesting
{
static class Program
private static readonly TestingEntity[] _dataSource1 = { new TestingEntity { Name = "First", PropertyId = 1 }, new TestingEntity { Name = "Second", PropertyId = 2 } };
private static readonly TestingEntity[] _dataSource2 = { new TestingEntity { Name = "Second", PropertyId = 2 } };
private static readonly TestingEntity _entity = new TestingEntity { PropertyId = 1 };
private static UltraComboEditor _editor;
[STAThread]
static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (var bindingSource = new BindingSource())
using (var form = new Form())
bindingSource.DataSource = _entity;
_editor = new UltraComboEditor
Dock = DockStyle.Top,
DisplayMember = nameof(TestingEntity.Name),
ValueMember = nameof(TestingEntity.PropertyId),
DropDownStyle = DropDownStyle.DropDownList,
DataSource = _dataSource1
};
_editor.DataBindings.Add(nameof(UltraComboEditor.Value), bindingSource, nameof(TestingEntity.PropertyId), true, DataSourceUpdateMode.OnPropertyChanged);
form.Controls.Add(_editor);
var button = new UltraButton
Dock = DockStyle.Top
button.Click += ButtonOnClick;
form.Controls.Add(button);
Application.Run(form);
}
private static void ButtonOnClick(object sender, EventArgs e)
_editor.DataSource = _dataSource2;
_entity.PropertyId = 2;
public class TestingEntity
private decimal _propertyId;
public string Name { get; set; }
public decimal PropertyId
get { return _propertyId; }
set
_propertyId = value;
Debug.WriteLine($"{nameof(PropertyId)} changed to {value}");
I had an issue like this, i will try too
Thanks
Hello doctorwc,
I've investigated your issue and found that your issue is not in our control, but in how to use DataBindings.
I tried using a Label object and binding it to the data source exactly in the same way as in your code snippet. And even with a label object, the binding does not work.I attached that application. Run it, and click the button several times. You'll see the label text does not change eighter.
Since DataBinidngs itself is of standard .NET Framework, could you review and debug your code by yourself so that DataBindings works expectedly?
If you need further assistance, please let me know.
Best Regards,
Noriko I.Developper Support EngineerInfragistics, Inc.