Glossary Item Box

Samples | Walkthroughs

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Adding Code for the Main Menu

This walkthrough is split up into the following activities:

Adding code for the Print Preview menu item

To write the code in Visual Basic

To write the code in C#

The following example shows what the code for the method looks like.

' Visual Basic
Private Sub mnuPrintPreview_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles mnuPrintPreview.Click
Dim rpt As New DataDynamics.ActiveReports.ActiveReport()
Dim m_stream As New System.IO.MemoryStream()
Me.Designer1.Report.SaveLayout(m_stream)
m_stream.Position = 0
rpt.LoadLayout(m_stream)
m_stream.Close()
Dim frm As New frmViewer()
frm.SetReport(rpt)
frm.ShowDialog(Me)
End Sub
//C#
private void mnuPrintPreview_Click(object sender, System.EventArgs e)
{
DataDynamics.ActiveReports.ActiveReport rpt = new DataDynamics.ActiveReports .ActiveReport();
System.IO.MemoryStream m_stream = new System.IO.MemoryStream();
this.designer1.Report.SaveLayout(m_stream);
m_stream.Position = 0;
rpt.LoadLayout(m_stream);
m_stream.Close();
frmViewer frm = new frmViewer();
frm.SetReport(rpt);
frm.ShowDialog(this);
}

Adding code for the Load Layout menu item

To write the code in Visual Basic

To write the code in C#

The following example shows what the code for the method looks like.

' Visual Basic
Private Sub mnuLoadLayout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuLoadLayout.Click
Me.Designer1.ExecuteAction(DesignerAction.FileOpen)
End Sub
//C#
private void mnuLoadLayout_Click(object sender, System.EventArgs e)
{
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.DesignerAction .FileOpen);
}

Adding code for the Save Layout menu item

To write the code in Visual Basic

To write the code in C#

The following example shows what the code for the method looks like.

' Visual Basic
Private Sub mnuSaveLayout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuSaveLayout.Click
Me.Designer1.ExecuteAction(DesignerAction.FileSave)
End Sub
//C#
private void mnuSaveLayout_Click(object sender, System.EventArgs e)
{
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.DesignerAction .FileSave);
}

Adding code for the Page Setup menu item

To write the code in Visual Basic

To write the code in C#

The following example shows what the code for the method looks like.

' Visual Basic
Private Sub mnuPageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuPageSetup.Click
Me.Designer1.ExecuteAction(DesignerAction.ReportSettings)
End Sub
//C#
private void mnuPageSetup_Click(object sender, System.EventArgs e)
{
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.DesignerAction .ReportSettings);
}

Adding code for the Exit menu item

To write the code in Visual Basic

To write the code in C#

The following example shows what the code for the method looks like.

' Visual Basic
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuExit.Click
Me.Close()
End Sub
//C#
private void mnuExit_Click(object sender, System.EventArgs e)
{
this.Close();
}

Samples | Walkthroughs

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.