New to Telerik UI for WinForms? Download free 30-day trial

How to use Inking in a WinForms application

Product Version Product Author Last modified
2017.2.502 RadGridView for WinForms Dimitar Karamfilov January 11, 2018

The below example demonstrates how one can use the InkEdit control which comes with the Microsoft Tablet PC Platform SDK, to enter data in RadGridView using a pen device. ink1

First, you need to add a reference to the Microsft.Ink.dll. This assembly is part of the Microsoft Tablet PC Platform SDK (1.7 is the latest version).

Detailed information about the ink support in WinForms and WPF can be found in the following article: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/the-ink-object-model-windows-forms-and-com-versus-wpf#enabling-ink-in-an-application

Let’s start with the example.

To use pen input, we will first need a custom editor which will host the InkEdit control. The InkEdit control inherits the standard RichTextBox, therefore we need RadHostItem in order to add it inside RadGridView.

class GridInkEditor : BaseGridEditor
{
    InkEdit inkEdit1;
    public override object Value
    {
        get
        {
            return inkEdit1.Text;
        }

        set
        {
            inkEdit1.Text = value == null ? "" : value.ToString();
        }
    }
    protected override RadElement CreateEditorElement()
    {
        this.inkEdit1 = new InkEdit();
        this.inkEdit1.RecoTimeout = 1000;


        this.inkEdit1.UseMouseForInput = true;

        var host = new RadHostItem(inkEdit1);
        host.BackColor = System.Drawing.Color.White;
        return host;
    }
}

When the editor is created we should add a GridViewTextBoxColumn which will display the text. Once the users start editing operation, the InkControl will appear and the user will be able to enter the data using a pen.

public RadForm1()
{
    InitializeComponent();
    radGridView1.Columns.Add(new GridViewTextBoxColumn() { Name = "InkColumn" });
    radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    radGridView1.EnableGrouping = false;
    radGridView1.AllowAddNewRow = false;

    for (int i = 0; i < 10; i++)
    {
        radGridView1.Rows.Add("Row Index" + i);

    }
    radGridView1.Font = new Font("Segoe UI", 16, FontStyle.Regular);
    radGridView1.TableElement.RowHeight = 50;
    radGridView1.EditorRequired += RadGridView1_EditorRequired;
}

private void RadGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (radGridView1.CurrentColumn.Name == "InkColumn")
    {
        e.EditorType = typeof(GridInkEditor);
    }
}

You can download a VB and C# project from the following link.

In this article