New to Telerik UI for WinFormsStart a free 30-day trial

Adding a Canvas for Free Hand Typing in WinForms Apps

Updated over 6 months ago

Environment

Product VersionProductAuthor
2024.2.514UI for WinFormsDinko Krastev

Description

This KB article demonstrates how we can implement a freehand drawing canvas in WinForms.

Solution

To achieve free hand typing or drawing in a WinForms application, we can use the InkCanvas element. To add the WPF object in WinForms Form, we can use the ElementHost class.

Note that InkCanvas is not a native WinForms control and requires additional assemblies (PresentationCore, PresentationFramework, and WindowsFormsIntegration) to integrate with WinForms.

To use InkCanvas in a WinForms application, follow these steps:

C#
     ElementHost host = new ElementHost();
     host.Dock = DockStyle.Fill;
     InkCanvas ic = new InkCanvas();
     host.Child = ic;
     this.radPanel1.Controls.Add(host);

See Also