gpt4 book ai didi

c# - 使用 C# 使用 crystalreportsviewer 打开表单

转载 作者:行者123 更新时间:2023-11-30 22:17:27 33 4
gpt4 key购买 nike

我正在处理一个应用程序。在 datagridview 中,我创建了事件 dataGridView1_CellContentDoubleClick,它应该打开另一个具有 crystalreportviewer 组件 的表单,然后将 crystalreportdocument 的路径传递给 crystalreportviewer 并加载该报告,以便它可以当前数据...

到目前为止我已经这样做了:

    private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
//string that carries path of the report document
string path = dataGridView1.SelectedRows[0].Cells["ReportPath"].Value.ToString();

}

Form3 看起来像:

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ICAMReports
{
public partial class Form3 : Form
{
public Form3(string path)
{
InitializeComponent();
}
}
}

Form3.Designer 看起来像:

namespace ICAMReports
{
partial class Form3
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{

this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this.SuspendLayout();
//
// crystalReportViewer1
//
this.crystalReportViewer1.ActiveViewIndex = -1;
this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default;
this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
this.crystalReportViewer1.Name = "crystalReportViewer1";
this.crystalReportViewer1.Size = new System.Drawing.Size(609, 413);
this.crystalReportViewer1.TabIndex = 0;
//
// Form3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(609, 413);
this.Controls.Add(this.crystalReportViewer1);
this.Name = "Form3";
this.Text = "Form3";
this.ResumeLayout(false);

}

#endregion

private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
}
}

最佳答案

您在项目中创建了一个新表单。然后在该表单的代码中,您更改构造函数以采用作为报告路径的字符串参数。

然后用来显示该表单的代码是:

//CrystalReportForm is your new form.
CrystalReportForm form = new CrystalReportForm(path);
form.Show(); //or form.ShowDialog();

关于c# - 使用 C# 使用 crystalreportsviewer 打开表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16706979/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com