BindingSource似乎不包含在部分类中创建的属性 [英] BindingSource doesn't appear to contain Properties created in partial class

查看:125
本文介绍了BindingSource似乎不包含在部分类中创建的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试绑定一个Linq-To-SQL查询的结果,我已经设置了填充图表。沿着X轴的日期和沿Y轴的货币。有两个系列,一个是钱,一个用于钱。



到目前为止还不够简单。



我想添加第三个系列,即贸易平衡,即收入与外向的差异。我为此创建了一个部分类,它使用生成的代码中的字段来计算正确的数字。



一切顺利,直到我尝试将其绑定到我的图形。计算的属性根本不会出现在可视化工作室内的绑定源下拉框中...所有其他属性(即不在部分中的属性)可以正常工作。



我已经测试过我的部分作品,并具有正确的命名空间 - 我可以手动进行测试,证明它可以正常工作,问题在于VS似乎没有看到使用部分添加的属性。



编辑:此外,我还确保属性是公开的。



任何想法?

解决方案

Tobias建议,手动绑定,似乎工作正常。



似乎是Visual Studio的成员解决方案是责怪的。有趣的是,如果数据对象在不同的​​程序集中没有问题,我猜是由于VS解决不同程序集中的类的方式。


I am trying to bind to the results of a Linq-To-SQL query, which I have set to populate a graph.

The graph is along the lines of Date along the X-Axis and Money along the Y-Axis. There are two-series, one for money in, and one for money out.

Simple enough so far.

I wanted to add a third series which is "balance of trade", i.e. the difference between income and outgoing. I created a partial class for this, which uses the fields in the generated code in order to calculate the correct figure.

All goes well until I try to bind this to my graph. The calculated properties do not appear at all within the Binding Source drop down box within visual studio...all of the other Properties (i.e. the ones not in the partial) work fine.

I have tested that my partial works and has the correct namespace - I can manually do tests proving it works, the problem is simply that VS doesn't appear to see the properties I have added using the partial.

Edit: In addition, I have also made sure the properties are public.

Any ideas?

解决方案

As Tobias suggested, I have added the binding manually, which seems to work fine.

It seems it is Visual Studio's member resolution which is to blame. Interestingly if the data objects are in a different assembly there is no problem, I guess due to the way VS resolves classes from different assemblies.

这篇关于BindingSource似乎不包含在部分类中创建的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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