WinForms

Form1.cs

using DotNetBrowser;
using DotNetBrowser.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForms.FindTextSample
{
    public partial class Form1 : Form
    {        
        private Browser browser;
        private BrowserView browserView;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            browserView = new WinFormsBrowserView();
            browser = browserView.Browser;
            browser.LoadURL("google.com");
            panel1.Controls.Add((Control)browserView);

        }

        private void find_Click(object sender, EventArgs e)
        {
            if (findTextBox.Text != String.Empty)
            {
                SearchParams searchParams = new SearchParams(findTextBox.Text);

                if (browser.FindText(searchParams).NumberOfMatches == 0)
                {
                    MessageBox.Show("No matches!");
                }
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!browser.IsDisposed())
            {
                browserView.Dispose();
                browserView.Browser.Dispose();
            }
        }

        private void clear_Click(object sender, EventArgs e)
        {
            browser.StopFindingText(StopFindAction.CLEAR_SELECTION);
            findTextBox.Text = "";
        }
    }
}


WPF

MainWindow.xaml

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WPF.FindTextSample"
        xmlns:WPF="clr-namespace:DotNetBrowser.WPF;assembly=DotNetBrowser" x:Class="WPF.FindTextSample.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="677" Width="1269" Closing="Window_Closing">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25*"/>
            <RowDefinition Height="30
                           "/>
        </Grid.RowDefinitions>

        <WPF:WPFBrowserView Name="browserView" Grid.Row="0" />

        <Grid Name="gridPanel" Grid.Row="1" Height="30">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150*"/>
                <ColumnDefinition Width="76"/>
                <ColumnDefinition Width="76"/>
                <ColumnDefinition Width="400*"/>

            </Grid.ColumnDefinitions>
            <TextBox x:Name="textBox" Grid.Column="0"  Height="22" TextWrapping="Wrap"  Margin="20, 4, 15, 4"/>
            <Button x:Name="findButton" Grid.Column="1" Content="Find/Next" HorizontalAlignment="Center" VerticalAlignment="Center" Width="75" Height="22" Click="findButton_Click" Margin="0,0,1,0"/>
            <Button x:Name="clearButton" Grid.Column="2" Content="Clear" HorizontalAlignment="Center" VerticalAlignment="Center" Width="75" Height="22" Click="clearButton_Click" Margin="1,0,0,0"/>

        </Grid>
    </Grid>
</Window>


MainWindow.xaml.cs

using DotNetBrowser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF.FindTextSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            browserView.Browser.LoadURL("google.com");
        }

        private void findButton_Click(object sender, RoutedEventArgs e)
        {
            if (textBox.Text != String.Empty)
            {
                if (browserView.Browser.FindText(new SearchParams(textBox.Text)).NumberOfMatches == 0)
                {
                    MessageBox.Show("No matches!");
                }
            }
        }

        private void clearButton_Click(object sender, RoutedEventArgs e)
        {
            browserView.Browser.StopFindingText(StopFindAction.CLEAR_SELECTION);
            textBox.Text = "";
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!browserView.Browser.IsDisposed())
            {
                browserView.Dispose();
                browserView.Browser.Dispose();
            }
        }
    }
}