duheng
2025-02-17 3720316038d2d2e283d9ef3c4385b76c2b4ada34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using DevExpress.CodeParser;
using DevExpress.XtraReports.UI;
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
 
namespace HStation.WinFrmUI
{
    public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport
    {
        public XtraReport1()
        {
            InitializeComponent();
            ininal();
        }
 
        private SimulationPrintViewModel _printViewModel;
 
        public void SetBingdingData(SimulationPrintViewModel viewModel)
        {
            _printViewModel = viewModel;
        }
 
        private void ininal()
        {
            // 获取数据源
            List<Product> dataSource = CreateSampleProductList();
            // this.xrTable1.DataBindings.Add("Text", dataSource, "Price");
            this.DataSource = dataSource;
            xrTable2.DataBindings.Add("Text", dataSource, "Price");
            xrTable2.DataBindings.Add("Text", dataSource, "ProductName");
        }
 
        public class Product
        {
            public string ProductName { get; set; }
            public decimal Price { get; set; }
        }
 
        public List<Product> CreateSampleProductList()
        {
            List<Product> products = new List<Product>
    {
        new Product { ProductName = "苹果", Price = 5.99m },
        new Product { ProductName = "香蕉", Price = 3.99m },
        new Product { ProductName = "橙子", Price = 4.99m }
    };
 
            return products;
        }
    }
}