【问题标题】:How to read BindType prop from BindingSource?如何从 BindingSource 读取 BindType 属性?
【发布时间】:2009-09-11 11:34:29
【问题描述】:

我正在寻找绑定到 BindingSource 的读取对象类型。

在调试器模式下,我深入研究了 BndingSource 对象,发现名为“BindType”的非公共属性包含感兴趣的信息。

(还找到了包含此类信息的属性“ItemType” - 但我不确定如果 BS.Count == 0 它会起作用)

您能否建议如何阅读/访问该信息?

【问题讨论】:

    标签: .net data-binding c#-3.0


    【解决方案1】:

    我自己找到了解决方案 - 在这里给出 - 可能对某人有所帮助:)

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

    【讨论】:

      猜你喜欢
      • 2012-11-19
      • 1970-01-01
      • 2021-10-23
      • 2013-09-01
      • 2016-06-18
      • 2012-03-04
      • 1970-01-01
      • 2015-11-19
      • 1970-01-01
      相关资源
      最近更新 更多