Walkthrough: Adding Code for the End-User Report Designer
This walkthrough is split up into the following activities:
- Adding a protected enumeration to frmDesigner
- Adding code to the frmDesigner_Load event
- Adding code to the Designer1_SelectionChanged event
Adding a protected enumeration to frmDesigner
To write the code in Visual Basic
- Right-click in any section of frmDesigner, and click on View Code to display the code view for the Windows Form. Add the following code just below the "Windows Form Designer generated code" region.
To write the code in C#
- Double-click anywhere on frmDesigner to show the code view for the Windows Form. Add the following code just below the "Windows Form Designer generated code" region.
The following example shows what the code for the method looks like.
' Visual Basic
Protected Enum toolbarModes
singleControl
twoControls
multiControls
noControls
End Enum
//C#
protected enum toolbarModes
{
singleControl,
twoControls,
multiControls,
noControls,
}
Adding code to the frmDesigner_Load event
To write the code in Visual Basic
- Right-click in any section of frmDesigner, and click on View Code to display the code view for the Windows Form. At the top left of the code view for frmDesigner, click the drop-down arrow and select (Base Class Events). At the top right of the code window, click the drop-down arrow and select Load. This creates an event-handling method for the frmDesigner_Load event.
To write the code in C#
- Click at the top of frmDesigner to select the Windows Form. Click on the events icon in the Properties window to display available events for the section. Double-click Load. This creates an event-handling method for the frmDesigner_Load event.
The following example shows what the code for the method looks like.
' Visual Basic
Dim i As Integer
Dim cnt As Integer
Dim ctl As String
Dim doStatusChange As Boolean
Private Sub frmDesigner_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.fillClassName()
Me.fillFonts()
Me.fillFontSizes()
Me.setModes(toolbarModes.noControls)
Me.Designer1.Focus()
AddHandler Application.Idle, AddressOf Me.Idle
End Sub
//C#
bool doStatusChange;
private void frmDesigner_Load(object sender, System.EventArgs e)
{
this.fillClassName();
this.fillFonts();
this.fillFontSizes();
this.setModes(toolbarModes.noControls);
this.designer1.Focus();
Application.Idle += new System.EventHandler(this.Idle);
}
Adding code to the Designer1_SelectionChanged event
To write the code in Visual Basic
- Right-click in any section of frmDesigner, and click on View Code to display the code view for the Windows Form. At the top left of the code view for frmDesigner, click the drop-down arrow and select designer1. At the top right of the code window, click the drop-down arrow and select SelectionChanged. This creates an event-handling method for the Designer1_SelectionChanged event.
To write the code in C#
- Click in the designer window of frmDesigner to select Designer1. Click on the events icon in the Properties window to display available events for the section. Double-click SelectionChanged. This creates an event-handling method for the Designer1_SelectionChanged event.
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Designer1_SelectionChanged() Handles Designer1.SelectionChanged
selChangeReportToolbar()
selChangeLayoutToolbar()
selChangePropGrid()
End Sub
//C#
private void designer1_SelectionChanged()
{
selChangeReportToolbar();
selChangeLayoutToolbar();
selChangePropGrid();
}
Samples | Walkthroughs
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.