# Create Printable Panel

This example shows how you can implement printable panel. This can be very useful when you want to print several controls at once. To achieve this you can create a custom panel that inherits from RadPanel and implements the **IPrintable** interface. This interface contains four methods:

* **BeginPrint:** Called when the printing begins.

* **EndPrint:** Called when the printing ends.

* **PrintPage:** Prints the page with the specified number.

* **GetSettingsDialog:** Gets a print settings dialog that is specific for the printable object.

The first step would be to just create the custom class:

 

 

```C#
    
public class PrintablePanel : RadPanel, IPrintable

```

```VB.NET
Public Class PrintablePanel
    Inherits RadPanel
    Implements IPrintable

```

 

For the current example the **BeginPrint** and **EndPrint** methods should just return a hard-coded values:

 

 

```C#
    
public int BeginPrint(RadPrintDocument sender, PrintEventArgs args)
{
    return 1;
}
    
public bool EndPrint(RadPrintDocument sender, PrintEventArgs args)
{
    return true;
}

```

```VB.NET
Public Function BeginPrint(sender As RadPrintDocument, args As PrintEventArgs) As Integer Implements IPrintable.BeginPrint
    Return 1
End Function
Public Function EndPrint(sender As RadPrintDocument, args As PrintEventArgs) As Boolean Implements IPrintable.EndPrint
    Return True
End Function

```

 

In the **GetSettingsDialog** method you should just return an new settings dialog:

 

 

```C#
public Form GetSettingsDialog(RadPrintDocument document)
{
    return new PrintSettingsDialog(document);
}

```

```VB.NET
Public Function GetSettingsDialog(document As RadPrintDocument) As Form Implements IPrintable.GetSettingsDialog
    Return New PrintSettingsDialog(document)
End Function

```

 

The **PrintPage** method is the place where the panel would be converted to image and drawn:

 

 

```C#
    
public bool PrintPage(int pageNumber, RadPrintDocument sender, PrintPageEventArgs args)
{
    Bitmap bmp = new Bitmap(this.Width, this.Height);
    this.DrawToBitmap(bmp, new Rectangle(Point.Empty, this.Size));
    args.Graphics.DrawImage(bmp, Point.Empty);
        
    return false;
}

```

```VB.NET
Public Function PrintPage(pageNumber As Integer, sender As RadPrintDocument, args As PrintPageEventArgs) As Boolean Implements IPrintable.PrintPage
    Dim bmp As New Bitmap(Me.Width, Me.Height)
    Me.DrawToBitmap(bmp, New Rectangle(Point.Empty, Me.Size))
    args.Graphics.DrawImage(bmp, Point.Empty)
    Return False
End Function

```

 

Besides the interface methods implementation you can create the **Print** and **PrintPreview** methods:

 

 

```C#
    
public void Print()
{
    RadPrintDocument doc = this.CreatePrintDocument();
    doc.Print();
}
 
public void PrintPreview()
{
    RadPrintDocument doc = this.CreatePrintDocument();
    RadPrintPreviewDialog dialog = new RadPrintPreviewDialog(doc);
        
    dialog.ThemeName = this.ThemeName;
    dialog.ShowDialog();
}

```

```VB.NET
Public Sub Print()
    Dim doc As RadPrintDocument = Me.CreatePrintDocument()
    doc.Print()
End Sub
Public Sub PrintPreview()
    Dim doc As RadPrintDocument = Me.CreatePrintDocument()
    Dim dialog As New RadPrintPreviewDialog(doc)
    dialog.ThemeName = Me.ThemeName
    dialog.ShowDialog()
End Sub

```

 

The final method is **CreatePrintDocument**. It returns a new RadPrintDocument associated with the current instance:

 

 

```C#
private RadPrintDocument CreatePrintDocument()
{
    RadPrintDocument doc = new RadPrintDocument();
    doc.AssociatedObject = this;
    return doc;
}

```

```VB.NET
Private Function CreatePrintDocument() As RadPrintDocument
    Dim doc As New RadPrintDocument()
    doc.AssociatedObject = Me
    Return doc
End Function

```



## See Also

* [Customize RadPrintDocument](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/printing-support/how-to/customize-radprintdocument)
