我正在寻找读取对象类型绑定到 BindingSource .
在调试器模式下,我深入研究了BndingSource对象,发现了名为“的非公共属性” BindType “什么包含感兴趣的信息。
(也发现了财产) 项目类型 “什么也包含这样的信息?但如果BS.Count==0,我不确定它是否有效)
你能告诉我如何阅读/访问这些信息吗?
我自己也找到了解决方案——在这里给出——也许对某人有所帮助:)
private static string ObjectHostedByBS (BocBindingSource bs) { if (bs == null) return string.Empty; ITypedList tl = bs as ITypedList; var a = tl.GetItemProperties(null); // no prop read if (a == null || a.Count == 0) return null; return a[0].ComponentType.Name; }