作成日: 2022/08/22; 最終更新日: 2022/08/22
文書種別
使用方法
詳細
フォーム上にC1FlexViewerを配置せず、ボタンクリック時などにレポートのプレビュー画面を表示するには、次の2通りの方法が考えられます。
(1)C1FlexViewerDialogのShowメソッドを使用
C1FlexViewerDialogコントロールをフォーム上に追加し、そのDocumentSourceプロパティにC1FlexReportを割り当てたのち、Showメソッドを実行します。
◎サンプルコード(VB)
(2)C1FlexViewerを貼り付けたプレビュー用フォームを用意し、そのShowDialogメソッドを使用
ボタンクリック時に呼び出されるプレビュー用フォーム(Name:Form2)を別途作成し、C1FlexViewerを貼り付けます。
このフォームにC1FlexReport型のパブリックプロパティを追加し、C1FlexViewerのDocumentSourceとしてこのプロパティを指定します。
呼び出し元フォームにC1FlexReport(Name:C1FlexReport1)を追加します。ボタンクリックイベントにて、プレビュー用フォームの新規インスタンスを作成し、上述のパブリックプロパティにc1FlexReport1を設定したのち、プレビュー用フォームのShowDialogメソッドを実行します。
◎サンプルコード(VB)
(1)C1FlexViewerDialogのShowメソッドを使用
C1FlexViewerDialogコントロールをフォーム上に追加し、そのDocumentSourceプロパティにC1FlexReportを割り当てたのち、Showメソッドを実行します。
◎サンプルコード(VB)
Private Sub button1_Click_1(sender As Object, e As EventArgs) Handles button1.Click
' レポートの読み込み
C1FlexReport1.Load("..\..\test.flxr", "レポート 1")
C1FlexReport1.Render()
' レポートのプレビュー
C1FlexViewerDialog1.DocumentSource = C1FlexReport1
C1FlexViewerDialog1.Show()
End Sub
◎サンプルコード(C#)
private void button1_Click(object sender, EventArgs e)
{
// レポートの読み込み
c1FlexReport1.Load(@"..\..\test.flxr", "レポート 1");
c1FlexReport1.Render();
// レポートのプレビュー
c1FlexViewerDialog1.DocumentSource = c1FlexReport1;
c1FlexViewerDialog1.Show();
}
(2)C1FlexViewerを貼り付けたプレビュー用フォームを用意し、そのShowDialogメソッドを使用
ボタンクリック時に呼び出されるプレビュー用フォーム(Name:Form2)を別途作成し、C1FlexViewerを貼り付けます。
このフォームにC1FlexReport型のパブリックプロパティを追加し、C1FlexViewerのDocumentSourceとしてこのプロパティを指定します。
呼び出し元フォームにC1FlexReport(Name:C1FlexReport1)を追加します。ボタンクリックイベントにて、プレビュー用フォームの新規インスタンスを作成し、上述のパブリックプロパティにc1FlexReport1を設定したのち、プレビュー用フォームのShowDialogメソッドを実行します。
◎サンプルコード(VB)
(呼び出し元フォーム)
Private Sub button2_Click(sender As Object, e As EventArgs) Handles button2.Click
' レポートの読み込み
C1FlexReport1.Load("..\..\test.flxr", "レポート 1")
C1FlexReport1.Render()
' プレビュー用フォームの表示
Dim viewFrm As Form2 = New Form2()
viewFrm.FlexReport = C1FlexReport1
viewFrm.ShowDialog()
End Sub
(プレビュー用フォーム)
Imports C1.Win.FlexReport
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
C1FlexViewer1.DocumentSource = FlexReport
End Sub
Private c1FlexReport1 As C1FlexReport
Public Property FlexReport As C1FlexReport
Get
Return c1FlexReport1
End Get
Set(ByVal value As C1FlexReport)
c1FlexReport1 = value
End Set
End Property
End Class
◎サンプルコード(C#)
(呼び出し元フォーム)
private void button2_Click(object sender, EventArgs e)
{
// レポートの読み込み
c1FlexReport1.Load(@"..\..\test.flxr", "レポート 1");
c1FlexReport1.Render();
// プレビュー用フォームの表示
Form2 viewFrm = new Form2();
viewFrm.FlexReport = c1FlexReport1;
viewFrm.ShowDialog();
}
(プレビュー用フォーム)
using System.Windows.Forms;
using C1.Win.FlexReport;
namespace prj_FlexReport
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
c1FlexViewer1.DocumentSource = FlexReport;
}
public C1FlexReport FlexReport
{
get
{
return c1FlexReport1;
}
set
{
c1FlexReport1 = value;
}
}
}
}