Download User Guide - Perpetuum Software

Transcript
e.Handled = true;
Customizing the Report Viewer Component
Sometimes you may need to change standard interface of the Report Viewer component. For
example, it does not correspond to the style of your application or you need to modify the toolbar.
As an example, let us create the Report Viewer with no toolbar (to do it, we should set the
Report Sharp-Shooter
}
ShowToolBar properties of Report Viewer to false) and add onto the form three buttons for moving on
to the previous / next page of the report and for printing it. To do so, we will use the Actions collection
of the ReportViewer component. A correspondence between a management component and an Action is
set up by the ActionBind type methods. To bind the buttons to certain actions, it is necessary to
implement a class derived from ActionBind.
Here is an example of how it can be done:
public class ButtonActionBind : ActionBind
{
public ButtonActionBind(Button button)
{
SetComponent(button);
}
public Button Button
{
get
{
return this.Component as Button;
}
}
protected override void Bind()
{
Button.Click += new EventHandler(Button_Click);
}
protected override void Unbind()
{
Button.Click -= new EventHandler(Button_Click);
}
public override void Update()
{
if (Action != null)
{
Button b = Button;
b.Enabled = Action.Enabled;
b.Text = Action.Text;
b.Visible = Action.Visible;
}
}
private void Button_Click(object sender, EventArgs e)
{
109