RDLC 实现柱形图

一、关于RDLC实现柱形图,工具用的是:VS2013。

二、效果图:

三、步骤:(1)在Form1.cs设计视图中添加一个报表控件:ReportViewer

              (2)添加一个Report1.rdlc文件;

 

              (3)创建一个数据集:DateSet1.xsd

在DateSet1中创建一个表

               (4)返回Report1.rdlc,在改窗口上设计图表,先在左侧报表数据那里点击:新建——数据集

 

 

创建成功后可以看到:

然后在设计图那里,右键插入一个表,把数据集里面的参数拖到表中

再新建一个图表,选择柱状图,进行设计,如下图:

设计完整体图如下所示:

之后就是代码方面了:

using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace tiaoxingtu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)
        {

            //指定报表外的数据源
            DataTable table = new DataTable();
            table.Columns.Add("month", typeof(string));
            table.Columns.Add("num", typeof(int));
            table.Columns.Add("prices",typeof(int));
          
            table.Rows.Add("1", "200","100");
            //table.Rows.Add("1", "400");
            //table.Rows.Add("1", "100");
            //table.Rows.Add("1", "300");
            //table.Rows.Add("1", "200");
            table.Rows.Add("2", "300","150");
            //table.Rows.Add("2", "300");
            //table.Rows.Add("2", "300");
            //table.Rows.Add("2", "300");
            table.Rows.Add("3", "500","250");
            //table.Rows.Add("3", "500");
            //table.Rows.Add("3", "500");
            //table.Rows.Add("4", "100");
            //table.Rows.Add("4", "100");
            table.Rows.Add("4", "100","350");

            //添加数据源
            ReportDataSource rds = new ReportDataSource();
            rds.Name = "DataSet1";
            rds.Value = table;

            //向报表绑定数据源
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            ///---向报表查看器指定显示的报表
            this.reportViewer1.LocalReport.ReportPath = @"..\..\Report1.rdlc";
            this.reportViewer1.RefreshReport();
           
        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {
            
        }
    }
}
View Code

 

 

最后运行OK!

 参考:http://qiba78.blog.163.com/blog/static/87614822008024113455197/   往事随锋的日志。

 

转载于:https://www.cnblogs.com/liushengbiao-318/p/5879110.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值