[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
using System; using System.Data; using System.Windows.Forms; using Npgsql; namespace RDLReport { public partial class Form1 : Form { private fyiReporting.RdlViewer.ViewerToolstrip reportToolStrip; private fyiReporting.RdlViewer.RdlViewer rdlViewer1; public Form1() { InitializeComponent(); this.SuspendLayout(); // // rdlViewer(印刷プレビュー) // this.rdlViewer1 = new fyiReporting.RdlViewer.RdlViewer(); this.rdlViewer1.Cursor = System.Windows.Forms.Cursors.Default; this.rdlViewer1.Dock = System.Windows.Forms.DockStyle.Fill; this.rdlViewer1.dSubReportGetContent = null; this.rdlViewer1.Folder = null; this.rdlViewer1.HighlightAll = false; this.rdlViewer1.HighlightAllColor = System.Drawing.Color.Fuchsia; this.rdlViewer1.HighlightCaseSensitive = false; this.rdlViewer1.HighlightItemColor = System.Drawing.Color.Aqua; this.rdlViewer1.HighlightPageItem = null; this.rdlViewer1.HighlightText = null; this.rdlViewer1.Location = new System.Drawing.Point(0, 0); this.rdlViewer1.Name = "rdlViewer1"; this.rdlViewer1.PageCurrent = 1; this.rdlViewer1.Parameters = ""; this.rdlViewer1.ReportName = null; this.rdlViewer1.ScrollMode = fyiReporting.RdlViewer.ScrollModeEnum.Continuous; this.rdlViewer1.SelectTool = false; this.rdlViewer1.ShowFindPanel = false; this.rdlViewer1.ShowParameterPanel = false; this.rdlViewer1.ShowWaitDialog = true; this.rdlViewer1.Size = new System.Drawing.Size(580, 472); this.rdlViewer1.SourceFile = null; this.rdlViewer1.SourceRdl = null; this.rdlViewer1.TabIndex = 0; this.rdlViewer1.UseTrueMargins = true; this.rdlViewer1.Zoom = 0.4202973F; this.rdlViewer1.ZoomMode = fyiReporting.RdlViewer.ZoomEnum.FitPage; this.Controls.Add(this.rdlViewer1); /// /// 印刷ボタン等 /// reportToolStrip = new fyiReporting.RdlViewer.ViewerToolstrip(rdlViewer1); this.Controls.Add(reportToolStrip); this.ResumeLayout(false); /// /// レポートにデータ流し込み /// LoadData(); } private void LoadData() { // 流し込み用データ取得 (レポート側はDataTable で受け取るのでその準備) string constring = @"Server = 127.0.0.1; Port = 5432; User Id = postgres; Password = *****; Database = dvdrental;"; using (NpgsqlConnection conn = new NpgsqlConnection(constring)) { string sql = "Select * from staff where first_name='Mike';"; NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter(sql, conn); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); DataTable dt = dataSet.Tables[0]; try { // RDLファイル読み込み rdlViewer1.SourceFile = new Uri(@"C:\test.rdl"); //データ流し込み rdlViewer1.Report.DataSets["Data"].SetData(dataSet.Tables[0]); // パラメータにデータセット rdlViewer1.Parameters += string.Format("param1={0}", "スタッフ情報"); rdlViewer1.Rebuild(); } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.Message); } } } } }実行するとツールバー付きの印刷プレビュー画面が表示できる。