惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 天生舞男

多个平均数列的子查询 迁移sharepoint Sharepoint迁移数据库之绝版(只要照着做,一定能够迁移成功) Sharepoint的webpart 虚函数和非虚函数的调用基本原则 The visio to drawing project chart. - 天生舞男 About the deeply copy 学习程序的自我建议---从实际软件的源代码开始学习 MS bug "The connection pool" in Oracle 10g and the data sort according to specified filed on DataGrid control. How to get response content with specified post data by post method Post method tip automation服务器不能创建对象 Get the biggest common divisor rose破解 ArrayList按Index删除的问题 Recently expection RadioButtonList中选择框和文字对不齐的解决办法 resolve problem best method is find document from official document 看了宝玉的作品,心理甚是感叹
Using MSChart from a C# WinForm
天生舞男 · 2006-04-13 · via 博客园 - 天生舞男

Posted on 2006-04-13 11:18  天生舞男  阅读(3515)  评论()    收藏  举报

I have seen in some C# newsgroups that many people are asking for how to use an MSChart control in their WinForms. There are some examples available written in VB but I have yet not found any working examples written in C#. The MSDN help only has examples in VB code as well. So here’s finally an example of how to display your data in a chart without having to do any GDI programming yourself.
The MSChart control is from Microsoft Excel so you need to have Excel installed. First, add a reference to the MSChart control to Visual Studio’s toolbox. Select menu->Tools->Add/Remove Toolbox items, then the COM Components tab and look for Microsoft Chart Control version 6.0 (OLEBD).
Then add create a WinForm project and add an MSChart control to your form from the Toolbox and name it axMSChart. Now you can add the following code to you form’s load method or some other appropriate place.

// Create chart data for three computers. Data is in the form of number of transactions per minute.
// We will only display data gathered between 10:00 AM and 10:03 AM.

axMSChart.ChartData = new Object[5, 4] {{null, "Computer A", "Computer B", "Computer C"},
                                        {"10:00 AM", 123131, 242142, 254353},
                                        {"10:01 AM", 113121, 171345, 205432},
                                        {"10:02 AM", 126323, 281876, 269743},
                                        {"10:03 AM", 199833, 242122, 283445}};

// Add a title and legend on the right side of the chart.

axMSChart.Title.Text = "Performance";
axMSChart.Legend.Location.LocationType = MSChart20Lib.VtChLocationType.VtChLocationTypeRight;
axMSChart.Legend.Location.Visible = true;

// Add titles to the axes.

axMSChart.Plot.get_Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX, null).AxisTitle.Text = "Time";
axMSChart.Plot.get_Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY, null).AxisTitle.Text = "Transactions/minute";

// Set chart type.

axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dBar;

// Other available chart types are
// VtChChartType2dBar, VtChChartType3dLine, VtChChartType2dLine, VtChChartType3dArea,
// VtChChartType2dArea, VtChChartType3dStep, VtChChartType2dStep,
// VtChChartType3dCombination, VtChChartType2dCombination, VtChChartType2dPie and
// VtChChartType2dXY.

// Set whether all the series in the chart are stacked or not.

axMSChart.Stacking = false;