DataBinding Problem

2 posts, 0 answers
  1. Christian
    Christian avatar
    44 posts
    Member since:
    May 2012

    Posted 09 Jun 2016 Link to this post


    I've noticed a small problem with the commandbar controls and databinding. Maybe this is not a bug, but however the commandbar controls behave different to the "normal" (Telerik) controls.

    If you have something like this:

    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
            public RadForm1()
                List<myobject> source = new List<myobject>();
                BindingSource binding = new BindingSource();
                source.Add(new myobject(1, "a"));
                source.Add(new myobject(2, "b"));
                source.Add(new myobject(3, "c"));
                source.Add(new myobject(4, "d"));
                    commandBarTextBox1.DataBindings.Add("Text", binding, "MyProperty2", true, DataSourceUpdateMode.OnValidation);
                radTextBox1.DataBindings.Add("Text", binding, "MyProperty2", true, DataSourceUpdateMode.OnValidation);          
                binding.DataSource = source;
        public class myobject
            public int MyProperty1 { get; set; }
            public string MyProperty2 { get; set; }
            public myobject(int a, string b)
                MyProperty1 = a;
                MyProperty2 = b;

    the databinding of the commandbartextbox will crash but the radtextbox works fine.The problem is that the binding datasource is set after the control databinding. 

    Since the radcontrols and the .net controls work fine in this case it would be nice if the commandbar controls could too.

    (Why are the commandbarcontrols not derived from the radcontrols? or at least have the same base class?)

    Kind Regards,


  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 10 Jun 2016 Link to this post

    Hello Christian,

    Thank you for writing.

    The data source is set after the binding is added to the controls. The command bar text box is a RadElement and it requires the data source to be set when the binding is added. The text box control requires the binding to have data source when it is made visible and this is why it is working with it. 

    I hope this will be useful. 

    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top