MindFusion WinForms Programmer's Guide
Canvas Class
Remarks See Also
 





Represents a report item that provides a way to render custom contents within the report.

Namespace: MindFusion.Reporting
Assembly: MindFusion.Reporting

 Syntax

C#  Copy Code

public class Canvas : ReportItem

Visual Basic  Copy Code

Public Class Canvas
    Inherits ReportItem

 Remarks

The Canvas element does not provide any visualization by default. In order to perform rendering through the Canvas, you need to handle its RenderContents event and place the custom drawing code in the event handler.

The following example illustrates how to render a rectangle using a Canvas object. The example assumes that canvas1 is a variable that references a valid Canvas instance.

C#  Copy Code

canvas1.RenderContents += new DrawCanvasEventHandler(this.OnDrawCanvas);

// ...

private void OnDrawCanvas(object sender, DrawCanvasEventArgs e)
{
    // Render a black rectangle
    e.Graphics.DrawRectangle(Pens.Black, e.Bounds);
}

Visual Basic  Copy Code

AddHandler(canvas1.RenderCanvas, AddressOf Me.OnDrawCanvas)

' ...

Private Sub OnDrawCanvas(ByRef sender As Object, ByRef e As DrawCanvasEventArgs)

    ' Render a black rectangle
    e.Graphics.DrawRectangle(Pens.Black, e.Bounds)

End Sub

The Canvas element can be data-bound, similarly to a Label or a Picture. In this case, the value retrieved from the data source can be accessed through the DataValue property of the DrawCanvasEventArgs object passed to the RenderContents event handler. The type of this value depends on the type of the field the Canvas is data-bound to.

To learn more about data-binding, visit the Binding Reports to a Data Source.

 Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            MindFusion.Reporting.ReportItem
                MindFusion.Reporting.Canvas

 See Also

Canvas Members
MindFusion.Reporting Namespace