从 GUI 填充的 MS 图表系列获取数据绑定成员
我有一组表格中的图表。这些是“罐装”图表,仅在新数据出现时才会更新(通常每月一次)。我通过使用“属性”滑出窗口在 VS2010 中将数据源绑定(绑定?)来创建每个图表。我将数据源设置为在 .XSD 文件中设置的数据源表。在 Series 属性 GUI 中,我已根据上一步中设置的数据表中的可用列设置了 XValueMember 和 YValueMember。 我的数据集中有 6 个表。 在我的表单中,一张表与一张图表(Chart1、Chart2、Chart3 等)相关。
我想要做的是以编程方式从图表属性中获取数据表名称。 我尝试过做类似的事情:
ch1Table = Chart1.DataSource.DataMember.ToString
但是,由于 Option Strict 不允许后期绑定,这会失败。我可能在这里遗漏了一些明显的东西,但我看不到它。
那么,如何从图表的设置属性中获取绑定的数据表名称呢? 我正在使用 MSChart Control 4 和 VS2010 并构建 VB.NET WinForms 应用程序。
编辑以扩展问题: 对于 6 个图表中的每一个,都有一个关联的 System.Windows.Forms.BindingSource。我需要做的是以编程方式获取 BindingSource,然后获取每个图表的 DataMember(这是我需要的表名称)。
I have a set of charts in a form. These are "canned" charts and will only be updated when new data comes in (typically on a monthly basis). I have created each chart by binding (bounding?) a data source to it in VS2010 using the Properties slide out window. I set the DataSource to a data source table that I set up in the .XSD file. In the Series property GUI I have set up the XValueMember and YValueMembers from the available columns in the data table I set in the previous step.
I have 6 tables in my DataSet.
One table relates to one Chart (Chart1, Chart2, Chart3, etc) in my form.
What I would like to do is programmatically get the data table name from the Chart properties.
I have tried doing something like:
ch1Table = Chart1.DataSource.DataMember.ToString
However this fails due to Option Strict disallowing late binding. I am probably missing something obvious here but I cannot see it.
So, how do I get the bound data table name from the set properties of the chart?
I am using MSChart Control 4 and VS2010 and building a VB.NET WinForms app.
EDIT to expand on question:
For each of the 6 charts there is an associated System.Windows.Forms.BindingSource
. What I need to do is programmatically get that BindingSource, then get the DataMember (which is the table name I need) for each chart.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同事苦苦思索并想出:
这为我提供了所需的表名称。
Fellow worker hammered away at it and came up with:
This provides me with the table name as desired.