How can I add a pie chart to my winforms application?

喜你入骨 提交于 2019-12-23 08:09:05

问题


I am trying to add a pie chart to my winforms application - but the only chart I can find in my toolbox is the regular bar chart.

Is there any way to form this bar chart as a pie chart or add a pie-chart component to my toolbox by using some existing .net 4 framework libraries (without installing any new libraries such as "DevExpress" etc)?


回答1:


Without third party tools the only way around it would be for you to create a new user control in WPF for this following this tutorial:

http://www.codeproject.com/Articles/28098/A-WPF-Pie-Chart-with-Data-Binding-Support

And then hosting this within the windows form project, following this tutorial:

http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms

That way you have created the control yourself without the need of downloading anything, although you may need to context switch to use the WPF tutorial - I hope this is ok :)




回答2:


You can change the chart type by selecting the series in property window or use the following sample code

 chart1.Series["Business"].ChartType =   
       System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;



回答3:


In .NET 4 and later I think you have MS Chart in the framework. Read more here: http://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61




回答4:


well actually visual studio does have a pie chart. after dragging out the bar chart. go to your properties panel then under chart click series. a dialog box will appear after which you will select chart type. there is a whole list of different chart types to choose from



来源:https://stackoverflow.com/questions/12250747/how-can-i-add-a-pie-chart-to-my-winforms-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!