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

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

问题描述

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



就像grid.DataSource = MyCustomClass是可用的。我不能直接访问数据库[其删除服务]。

 <$ c 

$ c> class CustomClass
{
string name;
string number;

public string名称
{
设置
{
返回名称;
}
}

public string Number
{
set
{
return number;
}
}

}
CustomClass custom = new CustomClass();

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

reportViewer.DataSource = custom;

是否有类似的东西可用。

解决方案

查看此链接:



http://msdn.microsoft.com/en-us/library/ms227595(VS.80).aspx



它会告诉你如何做到这一点。你可以查看我的答案这个问题的例子。
如何使用Crystal Reports而不使用紧密连接的数据库连接?



这里的快速解释是你应该能够将自定义对象添加到ArrayList中,然后使用ArrayList作为数据源。希望这有助于。


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.

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.

I want some thing like

    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 ;

Is it anything similar to this is available.

解决方案

Take a look at this link:

http://msdn.microsoft.com/en-us/library/ms227595(VS.80).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?

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.

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

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