【发布时间】:2009-09-11 11:34:29
【问题描述】:
我正在寻找绑定到 BindingSource 的读取对象类型。
在调试器模式下,我深入研究了 BndingSource 对象,发现名为“BindType”的非公共属性包含感兴趣的信息。
(还找到了包含此类信息的属性“ItemType” - 但我不确定如果 BS.Count == 0 它会起作用)
您能否建议如何阅读/访问该信息?
【问题讨论】:
标签: .net data-binding c#-3.0
我正在寻找绑定到 BindingSource 的读取对象类型。
在调试器模式下,我深入研究了 BndingSource 对象,发现名为“BindType”的非公共属性包含感兴趣的信息。
(还找到了包含此类信息的属性“ItemType” - 但我不确定如果 BS.Count == 0 它会起作用)
您能否建议如何阅读/访问该信息?
【问题讨论】:
标签: .net data-binding c#-3.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;
}
【讨论】: