9using System.Collections.Generic;
10using System.ComponentModel;
11using System.Windows.Forms;
21 public static class BindingSourceHelper
23 private static BindingSourceNode _rootSourceNode;
37 public static BindingSourceNode InitializeBindingSourceTree(
38 IContainer container, BindingSource rootSource)
40 if (rootSource ==
null)
43 _rootSourceNode =
new BindingSourceNode(rootSource);
44 _rootSourceNode.Children.AddRange(GetChildBindingSources(container, rootSource, _rootSourceNode));
46 return _rootSourceNode;
49 private static List<BindingSourceNode> GetChildBindingSources(
50 IContainer container, BindingSource parent, BindingSourceNode parentNode)
52 List<BindingSourceNode> children =
new List<BindingSourceNode>();
54 foreach (Component component
in container.Components)
56 if (component is BindingSource)
58 BindingSource temp = component as BindingSource;
59 if (temp.DataSource !=
null && temp.DataSource.Equals(parent))
61 BindingSourceNode childNode =
new BindingSourceNode(temp);
62 children.Add(childNode);
63 childNode.Children.AddRange(GetChildBindingSources(container, temp, childNode));
64 childNode.Parent = parentNode;
A strongly-typed resource class, for looking up localized strings, etc.
static string BindingSourceNotProvided
Looks up a localized string similar to A root binding source has not been provided.