Search code examples
.netwinformsdata-bindingbindingsource

Why BindingSource component cannot see inherited properties?


I have defined classes:

public class Parent : IParent
{
    public string ParentText
    {
        get { return "ParentText"; }
    }
}

public interface IParent
{
    string ParentText { get;}
}

public class Child : Parent, IChild
{
    public string ChildText
    {
        get { return "ChildText"; }
    }
}

public interface IChild : IParent
{
    string ChildText { get;}
}

When I try to bind control to IChild instance, I can do this for ChildText property, but not for ParentText property. if I try to bind to Child instance, both properties are bindable. Why databinding mechanism does not see properties inherited from other interfaces?

EDIT: SharePoint Newbie is right: databindings work when defined by hand in code. However, I tried to define databindings in designer using BindingSource component. When you add object source to project and point it to IChild interface, only ChildText is visible to define bindings.

I updated title of question to better reflect my problem.


Solution

  • I think, there is a bug in framework which causes described issue. Here is relevant connect issue:

    https://connect.microsoft.com/VisualStudio/feedback/details/431273/interface-inheritance-bug