如何从BindingSource的阅读BindType道具? [英] How to read BindType prop from BindingSource?

查看:176
本文介绍了如何从BindingSource的阅读BindType道具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找阅读对象类型绑定到的BindingSource

I'm looking for reading object type bind to BindingSource.

在调试模式下,我钻下去BndingSource对象,我发现一个名为 BindType 包含什么感兴趣的信息。非公共财产

In debugger mode I've drilled down BndingSource object and I've found non-public property named "BindType" what contains interested info.

(又发现属性的ItemType 什么也包含了这样的信息 - 但我不知道它会工作,如果BS.Count == 0)

(Also found property "ItemType" what contains also such info - but I'm not sure it will work if BS.Count == 0)

您可以请指教如何读/访问这些信息?

Can you please advice how to read / access that info ?

推荐答案

我已经找到自己的解决方案 - 给它在这里 - 也许可以帮助别人:)

I've found solution myself - giving it here - maybe helps someone :)

	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;
	}

这篇关于如何从BindingSource的阅读BindType道具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆