Sample projects on GitHub
The samples in this documentation are also available as complete, runnable projects in a public repository: github.com/spicelogic/winforms-html-editor-control-samples. Each one is a small Windows Forms application that references the shipping NuGet package, so there is nothing to wire up and no license key to obtain first - every sample runs on the free trial exactly as it is checked in.
The sample code is published under the MIT license, so you can copy any of it straight into your own application. The control itself remains commercial and is installed from NuGet.
What is in the repository
- 01-Quickstart - the smallest possible host: dock the editor, set
BodyHtml, and react toHtmlChanged. Start here if you want to see the control running in under a minute. - 02-LoadAndSaveHtml - open and save documents, and the practical difference between
BodyHtml, which is what you store in a database column, andDocumentHtml, which is the complete document including the head. - 03-PasteFromWord - intercepting the
Pastingevent to strip Word and Outlook markup before it reaches your document, with a before and after view so you can see what was removed. - 04-ToolbarCustomization - hiding built-in toolbar buttons and adding your own, so the toolbar matches your application rather than ours.
- 05-MailMergeTemplate - registering merge fields, turning on the built-in placeholder toolbar, and previewing a template with a record substituted in.
Which .NET version you need
Whichever one your application already uses. The control ships binaries for .NET Framework 4.5, 4.7.2 and 4.8, and for .NET 5, 6, 7, 8, 9 and 10 on Windows, so a long-lived Windows Forms application on .NET Framework 4.8 is a first-class target rather than a compatibility afterthought.
The samples are checked in targeting net8.0-windows purely as a default. The target framework lives in a single line of Directory.Build.props at the repository root, which all five projects inherit, so retargeting the whole set is one edit:
<TargetFramework>net48</TargetFramework>
Every sample is verified to build cleanly on net45, net472, net48, net8.0-windows and net10.0-windows. The one thing .NET Framework needs is the classic startup calls in place of the source-generated ApplicationConfiguration.Initialize(), and each Program.cs already carries that small conditional block, so nothing has to be edited by hand after retargeting.
Running the samples
You need Windows and the SDK matching whichever target you build against.
git clone https://github.com/spicelogic/winforms-html-editor-control-samples.git
cd winforms-html-editor-control-samples
dotnet build WinFormsHtmlEditorSamples.sln
dotnet run --project 01-Quickstart
You can also just open WinFormsHtmlEditorSamples.sln in Visual Studio and set any of the five projects as the startup project.
Building on WPF as well
The WPF edition of the control has its own sample repository covering MVVM binding, theming, toolbar customization, and mail merge: github.com/spicelogic/wpf-html-editor-control-samples. See the WPF HTML Editor control for the product itself.