知识大全 VC#.Net中浏览Crystal Report
Posted 知
篇首语:冲天香阵透长安,满城尽带黄金甲。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 VC#.Net中浏览Crystal Report相关的知识,希望对你有一定的参考价值。
VC#.Net中浏览Crystal Report 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
大名鼎鼎的 Crystal Reports(水晶报表)已内嵌为微软 Visual Studio NET的标准报表工具 同时升级到 Crystal Reports for Visual Studio NET 它的优点是 在 NET 平台能够轻松创建交互式的 高质量显现的报表内容 这也是 Crystal Reports 长期以来所具有的主要优势 使用 Crystal Reports for Visual Studio NET 可以在 Web 平台和 Windows 平台上承载报表 并将 Crystal 报表作为报表 Web 服务在 Web 服务器上发布 利用Crystal Report 创建的Web应用程序 使用户可以深化图表并根据需要筛选信息 在 NET 中 图表实际上就是一个与应用程序中其他控件进行交互的 Crystal 报表 在这里我向大家介绍如何在 Windows 窗体应用程序中浏览水晶报表 设计步骤 软件环境 要求系统已安装Visual Studio Net 集成开发系统 仅装有 Net Framework SDk 不能实现本例效果 成为 Net Framework SDK 没有水晶报表控件 新建一个 Visual C# 项目 Windows 应用程序 设置Form 的Text= 水晶报表浏览器 StartPosition=CenterScreen //程序开始出现在屏幕中央 其它属性均保持默认 从工具箱拖入一个CrystalReportViewer 一个Button 一个openFileDialog 到窗体 整个设计器的窗体布局只需将button 置于窗体底边中部 不再需要其它多余布局 设置crystalReportViewer 的属性如下 this crystalReportViewer Dock = System Windows Forms DockStyle Fill; //停靠方式为充满整个窗体//展开+DockPaddingthis crystalReportViewer DockPadding Bottom = ; //底部空出放置Button的区域this crystalReportViewer DockPadding Left = ; this crystalReportViewer DockPadding Right = ;this crystalReportViewer DockPadding Top = ;this crystalReportViewer ReportSource = null; //先不载入报表资源设置button 的属性如下 this button Anchor = System Windows Forms AnchorStyles Bottom;//与窗体的下边保持固定this button Text = 打开报表 ;openFileDialog 是打开文件的控件 设置其属性如下 this openFileDialog Filter = Crystal Report (* rpt)|* rpt|所有文件(* *)|* * ; //提供打开文件对话框的文件类型 默认类型就是此字符串的最前一种定义的类型this openFileDialog Title = 打开水晶报表 ; //打开文件对话框的标题 布局效果图如下 双击button 添加button _Click点击事件 private void button _Click(object sender System EventArgs e)tryif(openFileDialog ShowDialog()==DialogResult OK)this crystalReportViewer ReportSource = @openFileDialog FileName;//加载水晶报表 将报表文件绑定到CrystalReportView 控件;catch(Exception error)MessageBox Show(error ToString() 错误 ); OK!按Ctrl+F 运行吧 可以浏览你系统内现有的报表实例 \\Program Files\\Microsoft Visual Studio NET\\Crystal Reports\\Samples\\Reports\\Feature Examples\\Chart rptusing System;using System Drawing;using System Collections;using System ComponentModel;using System Windows Forms;using System Data;namespace WindowsApplication /// <summary>/// Form 的摘要说明 /// </summary>public class Form : System Windows Forms Formprivate CrystalDecisions Windows Forms CrystalReportViewer crystalReportViewer ;private System Windows Forms Button button ;private System Windows Forms OpenFileDialog openFileDialog ;/// <summary>/// 必需的设计器变量 /// </summary>private System ComponentModel Container ponents = null;public Form ()//// Windows 窗体设计器支持所必需的//InitializeComponent();//// TODO: 在 InitializeComponent 调用后添加任何构造函数代码///// <summary>/// 清理所有正在使用的资源 /// </summary>protected override void Dispose( bool disposing )if( disposing )if (ponents != null) ponents Dispose();base Dispose( disposing );#region Windows Form Designer generated code/// <summary>/// 设计器支持所需的方法 不要使用代码编辑器修改/// 此方法的内容 /// </summary>private void InitializeComponent()this crystalReportViewer = new CrystalDecisions Windows Forms CrystalReportViewer();this button = new System Windows Forms Button();this openFileDialog = new System Windows Forms OpenFileDialog();this SuspendLayout();// // crystalReportViewer // this crystalReportViewer ActiveViewIndex = ;this crystalReportViewer Dock = System Windows Forms DockStyle Fill;this crystalReportViewer DockPadding Bottom = ;this crystalReportViewer DockPadding Left = ;this crystalReportViewer DockPadding Right = ;this crystalReportViewer DockPadding Top = ;this crystalReportViewer Name = crystalReportViewer ;this crystalReportViewer ReportSource = null;this crystalReportViewer Size = new System Drawing Size( );this crystalReportViewer TabIndex = ;// // button // this button Anchor = System Windows Forms AnchorStyles Bottom;this button Location = new System Drawing Point( );this button Name = button ;this button TabIndex = ;this button Text = 打开报表 ;this button Click += new System EventHandler(this button _Click);// // openFileDialog // this openFileDialog Filter = Crystal Report (* rpt)|* rpt|所有文件(* *)|* * ;this openFileDialog Title = 打开水晶报表 ;// // Form // this AutoScaleBaseSize = new System Drawing Size( );this ClientSize = new System Drawing Size( );this Controls AddRange(new System Windows Forms Control[] this button this crystalReportViewer );this Name = Form ;this StartPosition = System Windows Forms FormStartPosition CenterScreen;this Text = 水晶报表浏览器 ;this ResumeLayout(false);#endregion/// <summary>/// 应用程序的主入口点 /// </summary>[STAThread]static void Main() Application Run(new Form ());private void button _Click(object sender System EventArgs e)tryif(openFileDialog ShowDialog()==DialogResult OK)this crystalReportViewer ReportSource = @openFileDialog FileName;//加载水晶报表 将资源报表绑定到水晶报表查看器catch(Exception error)MessageBox Show(error ToString() 错误 ); //处理异常错误 cha138/Article/program/net/201311/12997相关参考
知识大全 VC# .Net中使用Crystal Report(二)
VC#.Net中使用CrystalReport(二) 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
知识大全 VS2005+Crystal Report开发Web应用
VS2005+CrystalReport开发Web应用 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧
VC++.NET中使用GDI+创建特效字体 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!来自于微软
VC++.NET开发环境整合技巧 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 主窗口内的每一个
用VC.NET制作启动屏幕的新方法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 在利用VC+编
使用VC.net轻松实现按钮控件自绘 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 使用&nbs
VC.NET索引对查询条件顺序的影响 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 环境SqlS
VC.NET扩展Windows磁盘清理工具的功能 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
基于VC.NET的GDI+编程之CImage 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 我们
VC++.NET几个比较难缠的问题及其解决方法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 问