C#

Form1.cs

using DotNetBrowser;
using DotNetBrowser.DOM;
using DotNetBrowser.DOM.Events;
using DotNetBrowser.Events;
using DotNetBrowser.WinForms;
using System;
using System.Windows.Forms;

namespace DOMEventsSample
{
    public partial class Form1 : Form
    {
        private Browser browser;
        public Form1()
        {
            InitializeComponent();

            browser = BrowserFactory.Create();
            BrowserView browserView = new WinFormsBrowserView(browser);

            this.Controls.Add((Control)browserView.GetComponent());

            DOMEventHandler domEvent = delegate(object sender, DOMEventArgs e)
            {
                DOMEventType eventType = e.Type;
                Console.Out.WriteLine("handleEvent = " + eventType);
            };

            browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
            {
                if (e.IsMainFrame)
                {
                    DOMDocument document = e.Browser.GetDocument();
                    //Here Google search buttons are found by names. You can use other criteria to find them.
                    var element = document.GetElementByName("btnK");
                    var element2 = document.GetElementByName("btnG");

                    element.AddEventListener(DOMEventType.OnClick,domEvent, false);
                    element2.AddEventListener(DOMEventType.OnClick, domEvent, false);
                }
            };

            browserView.Browser.LoadURL("http://www.google.com");
        }
    }
}


VB.NET

Form1.vb

Imports DotNetBrowser
Imports DotNetBrowser.DOM
Imports DotNetBrowser.DOM.Events
Imports DotNetBrowser.Events
Imports DotNetBrowser.WinForms


Public Partial Class Form1
    Inherits Form

    Private browser As Browser

    Public Sub New()
        InitializeComponent()
        browser = BrowserFactory.Create()
        Dim browserView As BrowserView = New WinFormsBrowserView(browser)
        CType(browserView, WinFormsBrowserView).Dock = DockStyle.Fill
        Me.Controls.Add(CType(browserView.GetComponent(), Control))
        Dim domEvent As DOMEventHandler = sub(ByVal sender As Object, ByVal e As DOMEventArgs)
            Dim eventType As DOMEventType = e.Type
            Console.Out.WriteLine("handleEvent = " & eventType)
        End sub

        AddHandler browserView.Browser.FinishLoadingFrameEvent,
            sub(ByVal sender As Object, ByVal e As FinishLoadingEventArgs)

                If e.IsMainFrame Then
                    Dim document As DOMDocument = e.Browser.GetDocument()
                    'Here Google search buttons are found by names. You can use other criteria to find them.
                    Dim element = document.GetElementByName("btnK")
                    Dim element2 = document.GetElementByName("btnG")
                    element.AddEventListener(DOMEventType.OnClick, domEvent, False)
                    element2.AddEventListener(DOMEventType.OnClick, domEvent, False)
                End If
            End sub

        browserView.Browser.LoadURL("http://www.google.com")
    End Sub
End Class