如何在水晶报表中将自定义类指定为数据源 [英] How to assign Custom class as datasource in crystal report

查看:25
本文介绍了如何在水晶报表中将自定义类指定为数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了水晶报表,并通过数据-->对象生成了数据源,并从生成的数据源添加了字段.我的问题是,如何将值分配给数据源.

I created crystal report and through Data-->object i generated the DataSource and i added the fields from generated Datasource. My problem is, how to assign the values to the datasource.

像 grid.DataSource = MyCustomClass 这样的东西是否可用.我无法直接访问数据库 [它是一个删除服务].赋值的方法是什么.

Is anything like grid.DataSource = MyCustomClass is available. I can't access the Database directly [its a remove service]. What is the way to assign the values.

我想要一些类似的东西

    class CustomClass
    {
      string name;  
      string number;

       public string Name
       {
       set
       {
         return name;
       }
       }

       public string Number
       {
       set
       {
           return number;
        }
       }

    }
CustomClass custom = new CustomClass ();

custom.Name = "Mohan";
custom.Number = "100";

reportViewer.DataSource = custom ;

有没有类似的东西.

推荐答案

看看这个链接:

https://msdn.microsoft.com/en-us/library/ms227595.aspx

它将向您展示如何做到这一点.例如,您可以查看我对这个问题的回答.如何在没有水晶报表的情况下使用紧密链接的数据库连接?

It will show you how this can be done. You can view my answer on this question for an example. How to use Crystal Reports without a tightly-linked DB connection?

对此的快速解释是,您应该能够将自定义对象添加到 ArrayList 中,然后使用 ArrayList 作为数据源.希望这会有所帮助.

The quick explanation for this is that you should be able to add your custom object into an ArrayList and then use the ArrayList as the datasource. Hope this helps.

这篇关于如何在水晶报表中将自定义类指定为数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆