如何从BindingSource读取BindType prop? [英] How to read BindType prop from BindingSource?

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

问题描述

我正在寻找读取对象类型绑定到 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 prop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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