来自c#中datagridview的ms图表 [英] ms chart from datagridview in c#

查看:50
本文介绍了来自c#中datagridview的ms图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序中有一个数据网格。我想根据两个列值绘制图表。

员工ID和Perfomance列。

员工ID列包含字符串值如EMP002。

Perfomance列包含百分比值。





i尝试此代码

i having a data grid in my program.i want to plot a chart according to two colum values.
employee id and Perfomance colum.
employee Id colum contain string value like EMP002.
Perfomance column contain percentage values.


i tried this code

chart1.DataSource = dataGridView1;
           chart1.Series["series1"].XValueMember = "Employee Id";
           chart1.Series["series1"].YValueMembers = "Perfomance";
           chart1.DataBind();





但是我喜欢-----一个带有名字的图表元素在'SeriesCollection'中找不到'series1'。









我该怎么做



but i am gettin aerror like-----A chart element with the name 'series1' could not be found in the 'SeriesCollection'.




HOW CAN I DO THIS

推荐答案

我认为你不能将DataGridView绑定到MS Chart控件。可以通过绑定使用的受支持类型列表



•SqlCommand

•OleDbCommand

•SqlDataAdapter

•OleDbDataAdapter

•DataView

•DataSet

•DataReader

•List

•数组

•IList

•IListSource

•IEnumerable



尝试将源直接绑定到您的图表并从原始源提供x和y值。



更多帮助您可以看到数据绑定Microsoft图表控件 [ ^ ]
I do not think that you can bind DataGridView to a MS Chart control. List of supported types which can be used from binding are

•SqlCommand
•OleDbCommand
•SqlDataAdapter
•OleDbDataAdapter
•DataView
•DataSet
•DataReader
•List
•Array
•IList
•IListSource
•IEnumerable

try binding the source directly to your chart and providing the x and y values form original source.

more help you can see Data Binding Microsoft Chart Control[^]


您好,



请确保您有如下图形结构,

Hi,

Please make sure you have graph structure as below,
<asp:chart id="chart1" runat="server" xmlns:asp="#unknown">
	<series>
		<asp:series name="series1">
		</asp:series>                
	</series>
</asp:chart>





错误说你缺少给定名字的系列。





让我知道这是在ASP.NET还是在C#窗体中?

[/编辑]



祝你好运

~Amit



Error says that you are missing Series with the given name.


Let me know if this is in ASP.NET or in C# windows forms ?
[/Edit]

Best luck
~Amit


这篇关于来自c#中datagridview的ms图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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