c# 报表

1。新建windows应用程序。

2。新建报表a.rdlc

3。为报表a.rdlc设置数据源

4。创建reportviewer,设置报表为a.rdlc

using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsApplication1
{
    class BusinessObjects
    {
    }
    public class Product
    {
        private string m_name;
        private int m_price;

        public Product(string name, int price)
        {
            m_name = name;
            m_price = price;
        }

        public string Name
        {
            get
            {
                return m_name;
            }
        }

        public int Price
        {
            get
            {
                return m_price;
            }
        }
    }

    // Define Business Object "Merchant" that provides a
    //    GetProducts method that returns a collection of
    //    Product objects.

    public class Merchant
    {
        private List<Product> m_products;

        public Merchant()
        {
            m_products = new List<Product>();
            m_products.Add(new Product("Pen", 25));
            m_products.Add(new Product("Pencil", 30));
            m_products.Add(new Product("Notebook", 15));
        }

        public List<Product> GetProducts()
        {
            return m_products;
        }
    }

}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form2 : Form
    {
        private Merchant m_merchant = new Merchant();

        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            this.ProductBindingSource.DataSource = m_merchant.GetProducts();

            this.reportViewer1.RefreshReport();
        }
    }
}

转载于:https://www.cnblogs.com/ivan2984/archive/2010/12/08/1900430.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值