When you create a StrokesEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.
InkCollector theInkCollector = new InkCollector(Handle);
theInkCollector.Enabled = true;
// Add a handler for InkAdded Events to display
// their Ids in a listbox.
theInkCollector.Ink.InkAdded += new StrokesEventHandler(InkAdded_Event);
public void InkAdded_Event(object sender, StrokesEventArgs e)
int  theAddedStrokeIds = e.StrokeIds;
foreach (int i in theAddedStrokeIds)
listBox1.Items.Add("Added Stroke Id: " + i.ToString());
[Visual Basic .NET]
This Microsoft® Visual Basic® .NET example demonstrates adding an InkAdded event handler to an Ink object. The event handler writes information about the added strokes to a list box, ListBox1.
Dim theInkCollector As New InkCollector(Handle)
theInkCollector.Enabled = true
'Add a handler for InkAdded Events to display
'their Ids in a listbox.
AddHandler theInkCollector.Ink.InkAdded, AddressOf InkAdded_Event
Public Sub InkAdded_Event(ByVal sender as Object, _
ByVal e As StrokesEventArgs)
Dim theAddedStrokeIds() As Integer = e.StrokeIds
Dim i As Integer
For Each i In theAddedStrokeIds
ListBox1.Items.Add("Added Stroke Id: " & i.ToString())