BindingSource
is a Component
, not a Control
, so indeed you can't find it in the Controls
collection. However, when you add components with the designer, it creates a field named components
of type IContainer
and adds the components to it. The field is private, so you can only access it from the class in which it is declared (unless you use reflection).
I think the easiest way to achieve what you want is to add a GetBindingSources
method to all your using controls :
public IEnumerable<BindingSource> GetBindingSources()
{
return components.Components.OfType<BindingSource>();
}
Of course, it will work only for BindingSources
created with the designer, not for those you create dynamically (unless you add them to the container)