水晶报表的常用属性及方法

1、常用属性及方法

        //常用属性

        CrystalReportViewer1.HasToggleGroupTreeButton = true;//显示或隐藏工具栏上组树按钮

        CrystalReportViewer1.HasExportButton = true;//显示或隐藏工具栏上导出按钮

        CrystalReportViewer1.HasPrintButton = true;//显示或隐藏工具栏上打印按钮

        CrystalReportViewer1.HasViewList = true;//显示或隐藏工具栏上视图列表(主报表)

        CrystalReportViewer1.HasDrillUpButton = true;//获取或设置浅化按钮可见性(向上)

        CrystalReportViewer1.HasPageNavigationButtons = true;//显示或隐藏工具栏上导航按钮

        CrystalReportViewer1.HasGotoPageButton = true;//显示或隐藏工具栏上跳转按钮

        CrystalReportViewer1.HasSearchButton = true;//显示或隐藏工具栏上搜索按钮

        CrystalReportViewer1.HasZoomFactorList = true;//显示或隐藏工具栏上缩放按钮

        CrystalReportViewer1.HasCrystalLogo = true;//显示或隐藏工具栏上LOGO

CrystalReportViewer1.SelectionFormula = "{Customer.Last Year's Sales} > 11000.00 " + "AND Mid({Customer.Customer Name}, 1, 1) = \"A\"";//筛选公式

 

        CrystalReportViewer1.DisplayToolbar = true;//显示或隐藏工具栏

        CrystalReportViewer1.DisplayGroupTree = true;//显示或隐藏组树

        CrystalReportViewer1.DisplayPage = true;//显示或隐藏页面视图

        CrystalReportViewer1.SeparatePages = true;//获取或设置报表页是分开还是连接?

        CrystalReportViewer1.BorderWidth = Convert.ToInt32("borderWidth");//设置边框宽度

        //常用方法

        CrystalReportViewer1.ShowNthPage(Convert.ToInt32("pageNumber"));//跳转页

        CrystalReportViewer1.Zoom(Convert.ToInt32("zoomFactor"));//缩放

 

2、登陆验证

private void ConfigureCrystalReports()

    {

        ConnectionInfo connectionInfo = new ConnectionInfo();

        connectionInfo.ServerName = ".";

        connectionInfo.DatabaseName = "Northwind";

        connectionInfo.UserID = "sa";

        connectionInfo.Password = "";

        string reportPath = Server.MapPath("NorthwindCustomers.rpt");

        crystalReportViewer.ReportSource = reportPath;

        SetDBLogonForReport(connectionInfo);

    }

 

    private void Page_Init(object sender, EventArgs e)

    {

        ConfigureCrystalReports();

    }

    private void SetDBLogonForReport(ConnectionInfo connectionInfo)

    {

        TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnInfo;

        foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)

        {

            tableLogOnInfo.ConnectionInfo = connectionInfo;

        }

    }

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值