在 FROM 下打开水晶报表文件(代碼碎片)

来源:互联网 发布:mac用flash发热 编辑:程序博客网 时间:2024/05/17 08:48
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Windowsbaobiao
{
    
/// <summary>
    
/// Form1 的摘要说明。
    
/// </summary>

    public class Form2 : System.Windows.Forms.Form
    
{
        
private System.Windows.Forms.Button btnSelect;
        
private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
        
/// <summary>
        
/// 必需的设计器变量。
        
/// </summary>

        private System.ComponentModel.Container components = null;

        
public Form2()
        
{
            
//
            
// Windows 窗体设计器支持所必需的
            
//
            InitializeComponent();

            
//
            
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            
//
        }


        
/// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>

        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if (components != null
                
{
                    components.Dispose();
                }

            }

            
base.Dispose( disposing );
        }


        
Windows Form Designer generated code

        
/// <summary>
        
/// 应用程序的主入口点。
        
/// </summary>

        [STAThread]
        
static void Main() 
        
{
            Application.Run(
new Form2());
        }


        
private void btnSelect_Click(object sender, System.EventArgs e)
        
{
            OpenFileDialog dlg 
= new OpenFileDialog();
            dlg.Title 
= "打开水晶报表文件";
            dlg.Filter 
= "水晶报表文件(*.rpt)|*.rpt|所有文件|*.*";
            
if(dlg.ShowDialog()==DialogResult.OK)
            
{
                crystalReportViewer1.ReportSource 
= dlg.FileName;
            }

        }


        
private void Form2_Load(object sender, System.EventArgs e)
        
{
        
        }

    }

}