Selection Example for WinForms

Nevron NOV RichTextEditor for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms RichTextEditor examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Selection Example for WinForms Description

This example demonstrates how to use the selection object in order to select text as well as how to modify selected text appearance


Selection Example

C# Selection Example Code for Nevron RichTextEditor for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Text;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NSelectionExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			// Create the rich text
			NRichTextViewWithRibbon richTextWithRibbon = new NRichTextViewWithRibbon();
			m_RichText = richTextWithRibbon.View;
			m_RichText.AcceptsTab = true;
			m_RichText.Content.Sections.Clear();

			// Populate the rich text
			PopulateRichText();

			return richTextWithRibbon;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel groupsStack = new NStackPanel();

			// caret navigation
			{
				NGroupBox groupBox = new NGroupBox("Caret Navigation");
				groupsStack.Add(groupBox);

				NStackPanel stack = new NStackPanel();
				groupBox.Content = stack;

				NButton moveToNextWordButton = new NButton("Move Caret to Next Word");
				moveToNextWordButton.Click += OnMoveToNextWordButtonClick;
				stack.Add(moveToNextWordButton);

				NButton moveToPrevWordButton = new NButton("Move Caret to Prev Word");
				moveToPrevWordButton.Click += OnMoveToPrevWordButtonClick;
				stack.Add(moveToPrevWordButton);
			}

			{
				NGroupBox groupBox = new NGroupBox("Range Selection");
				groupsStack.Add(groupBox);

				NStackPanel stack = new NStackPanel();
				groupBox.Content = stack;

				NButton selectCurrentParagraphButton = new NButton("Select Current Paragraph");
				selectCurrentParagraphButton.Click += OnSelectCurrentParagraphButtonClick;
				stack.Add(selectCurrentParagraphButton);

				NButton deleteSelectedTextButton = new NButton("Delete Selected Text");
				deleteSelectedTextButton.Click += OnDeleteSelectedTextButtonClick;
				stack.Add(deleteSelectedTextButton);
			}

			{
				NGroupBox groupBox = new NGroupBox("Copy / Paste");
				groupsStack.Add(groupBox);

				NStackPanel pasteOptionsStack = new NStackPanel();
				groupBox.Content = pasteOptionsStack;

				{
					NButton copyButton = new NButton("Copy");
					copyButton.Click += OnCopyButtonClick;
					pasteOptionsStack.Add(copyButton);

					NButton pasteButton = new NButton("Paste");
					pasteButton.Click += OnPasteButtonClick;
					pasteOptionsStack.Add(pasteButton);

					NCheckBox allowImagesCheckBox = new NCheckBox("Allow Images");
					allowImagesCheckBox.CheckedChanged += OnAllowImagesCheckBoxCheckedChanged;
					allowImagesCheckBox.Checked = true;
					pasteOptionsStack.Add(allowImagesCheckBox);

					NCheckBox allowTablesCheckBox = new NCheckBox("Allow Tables");
					allowTablesCheckBox.CheckedChanged += OnAllowTablesCheckBoxCheckedChanged;
					allowTablesCheckBox.Checked = true;
					pasteOptionsStack.Add(allowTablesCheckBox);

					NCheckBox allowSectionsCheckBox = new NCheckBox("Allow Sections");
					allowSectionsCheckBox.CheckedChanged += OnAllowSectionsCheckBoxCheckedChanged;
					allowSectionsCheckBox.Checked = true;
					pasteOptionsStack.Add(allowSectionsCheckBox);
				}
			}

			{
				NGroupBox groupBox = new NGroupBox("Inline Formatting");
				groupsStack.Add(groupBox);

				NStackPanel stack = new NStackPanel();
				groupBox.Content = stack;

				NButton setBoldStyleButton = new NButton("Set Bold Style");
				setBoldStyleButton.Click += OnSetBoldStyleButtonClick;
				stack.Add(setBoldStyleButton);

				NButton setItalicStyleButton = new NButton("Set Italic Style");
				setItalicStyleButton.Click += OnSetItalicStyleButtonClick;
				stack.Add(setItalicStyleButton);

				NButton clearStyleButton = new NButton("Clear Style");
				clearStyleButton.Click += OnClearStyleButtonClick;
				stack.Add(clearStyleButton);
			}

			return groupsStack;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to use the selection object in order to select text as well as how to modify selected text appearance

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Rich Text Documents - Selection", "https://www.nevron.com/docs/openvision/rich-text-documents-selection.html"), ("Rich Text Range Elements", "https://www.nevron.com/docs/openvision/rich-text-range-elements.html"), }; } private void PopulateRichText() { NSection section = new NSection(); m_RichText.Content.Sections.Add(section); section.Blocks.Add(GetDescriptionBlock("Working With the Selection Object", "The example demonstrates how to work with the selection object.", 1)); for (int i = 0; i < 10; i++) { section.Blocks.Add(new NParagraph("Now it so happened that on one occasion the princess's golden ball did not fall into the little hand which she was holding up for it, but on to the ground beyond, and rolled straight into the water. The king's daughter followed it with her eyes, but it vanished, and the well was deep, so deep that the bottom could not be seen. At this she began to cry, and cried louder and louder, and could not be comforted. And as she thus lamented someone said to her, \"What ails you, king's daughter? You weep so that even a stone would show pity.\"")); } } #endregion #region Implementation #endregion #region Event Handlers void OnClearStyleButtonClick(NEventArgs arg) { m_RichText.Selection.ClearFontStyleFromSelectedInlines(ENFontStyle.Bold | ENFontStyle.Italic | ENFontStyle.Strikethrough | ENFontStyle.Underline); m_RichText.Focus(); } void OnSetItalicStyleButtonClick(NEventArgs arg) { m_RichText.Selection.AddFontStyleToSelectedInlines(ENFontStyle.Italic); m_RichText.Focus(); } void OnSetBoldStyleButtonClick(NEventArgs arg) { m_RichText.Selection.AddFontStyleToSelectedInlines(ENFontStyle.Bold); m_RichText.Focus(); } void OnPasteButtonClick(NEventArgs arg) { m_RichText.Selection.Paste(); m_RichText.Focus(); } void OnCopyButtonClick(NEventArgs arg) { m_RichText.Selection.SelectAll(); m_RichText.Selection.Copy(); m_RichText.Focus(); } void OnDeleteSelectedTextButtonClick(NEventArgs arg) { m_RichText.Selection.Delete(); m_RichText.Focus(); } void OnAllowTablesCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_RichText.Selection.PasteOptions.AllowTables = ((NCheckBox)arg.TargetNode).Checked; } void OnAllowSectionsCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_RichText.Selection.PasteOptions.AllowSections = ((NCheckBox)arg.TargetNode).Checked; } void OnAllowImagesCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_RichText.Selection.PasteOptions.AllowImages = ((NCheckBox)arg.TargetNode).Checked; } void OnSelectCurrentParagraphButtonClick(NEventArgs arg) { NInline inline = m_RichText.Selection.CaretInline; if (inline == null) return; NParagraph currentParagraph = inline.ParentBlock as NParagraph; if (currentParagraph != null) { m_RichText.Selection.SelectRange(currentParagraph.Range); } } void OnMoveToNextWordButtonClick(NEventArgs arg) { m_RichText.Selection.MoveCaret(ENCaretMoveDirection.NextWord, false); m_RichText.Focus(); } void OnMoveToPrevWordButtonClick(NEventArgs arg) { m_RichText.Selection.MoveCaret(ENCaretMoveDirection.PrevWord, false); m_RichText.Focus(); } #endregion #region Fields private NRichTextView m_RichText; #endregion #region Static Methods private static NParagraph GetDescriptionParagraph(string text) { return new NParagraph(text); } private static NParagraph GetTitleParagraphNoBorder(string text, int level) { double fontSize = 10; ENFontStyle fontStyle = ENFontStyle.Regular; switch (level) { case 1: fontSize = 16; fontStyle = ENFontStyle.Bold; break; case 2: fontSize = 10; fontStyle = ENFontStyle.Bold; break; } NParagraph paragraph = new NParagraph(); paragraph.HorizontalAlignment = ENAlign.Left; paragraph.FontSize = fontSize; paragraph.FontStyle = fontStyle; NTextInline textInline = new NTextInline(text); textInline.FontStyle = fontStyle; textInline.FontSize = fontSize; paragraph.Inlines.Add(textInline); return paragraph; } /// /// Gets a paragraph with title formatting /// /// /// private static NParagraph GetTitleParagraph(string text, int level) { NColor color = NColor.Black; NParagraph paragraph = GetTitleParagraphNoBorder(text, level); paragraph.HorizontalAlignment = ENAlign.Left; paragraph.Border = CreateLeftTagBorder(color); paragraph.BorderThickness = defaultBorderThickness; return paragraph; } private static NGroupBlock GetNoteBlock(string text, int level) { NColor color = NColor.Red; NParagraph paragraph = GetTitleParagraphNoBorder("Note", level); NGroupBlock groupBlock = new NGroupBlock(); groupBlock.ClearMode = ENClearMode.All; groupBlock.Blocks.Add(paragraph); groupBlock.Blocks.Add(GetDescriptionParagraph(text)); groupBlock.Border = CreateLeftTagBorder(color); groupBlock.BorderThickness = defaultBorderThickness; return groupBlock; } private static NGroupBlock GetDescriptionBlock(string title, string description, int level) { NColor color = NColor.Black; NParagraph paragraph = GetTitleParagraphNoBorder(title, level); NGroupBlock groupBlock = new NGroupBlock(); groupBlock.ClearMode = ENClearMode.All; groupBlock.Blocks.Add(paragraph); groupBlock.Blocks.Add(GetDescriptionParagraph(description)); groupBlock.Border = CreateLeftTagBorder(color); groupBlock.BorderThickness = defaultBorderThickness; return groupBlock; } /// /// Creates a left tag border with the specified border /// /// /// private static NBorder CreateLeftTagBorder(NColor color) { NBorder border = new NBorder(); border.LeftSide = new NBorderSide(); border.LeftSide.Fill = new NColorFill(color); return border; } private static NParagraph GetLoremIpsumParagraph() { return new NParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum placerat in tortor nec tincidunt. Sed sagittis in sem ac auctor. Donec scelerisque molestie eros, a dictum leo fringilla eu. Vivamus porta urna non ullamcorper commodo. Nulla posuere sodales pellentesque. Donec a erat et tortor viverra euismod non et erat. Donec dictum ante eu mauris porta, eget suscipit mi ultrices. Nunc convallis adipiscing ligula, non pharetra dolor egestas at. Etiam in condimentum sapien. Praesent sagittis pulvinar metus, a posuere mauris aliquam eget."); } #endregion #region Constants private static readonly NMargins defaultBorderThickness = new NMargins(5.0, 0.0, 0.0, 0.0); #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Selection Example for WinForms Solution

VB.NET Selection Example Code for Nevron RichTextEditor for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.Text
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NSelectionExample"

        ' Create the NOV example and its controls
        Dim exampleContent As NWidget = CreateExampleContent()
        Dim exampleControls As NWidget = CreateExampleControls()
        If Not exampleControls Is Nothing Then
            exampleControls.PreferredWidth = 300
        End If

        ' Place the example and its controls in a pair box
        Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
        pairBox.FillMode = ENStackFillMode.First
        pairBox.FitMode = ENStackFitMode.First
        pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

        ' Host the example in the form
        Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
        host.Dock = DockStyle.Fill
        Controls.Add(host)
    End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            ' Create the rich text
            Dim richTextWithRibbon As NRichTextViewWithRibbon = New NRichTextViewWithRibbon()
            m_RichText = richTextWithRibbon.View
            m_RichText.AcceptsTab = True
            m_RichText.Content.Sections.Clear()

            ' Populate the rich text
            PopulateRichText()

            Return richTextWithRibbon
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim groupsStack As NStackPanel = New NStackPanel()

            ' caret navigation
            If True Then
                Dim groupBox As NGroupBox = New NGroupBox("Caret Navigation")
                groupsStack.Add(groupBox)

                Dim stack As NStackPanel = New NStackPanel()
                groupBox.Content = stack

                Dim moveToNextWordButton As NButton = New NButton("Move Caret to Next Word")
                moveToNextWordButton.Click += AddressOf OnMoveToNextWordButtonClick
                stack.Add(moveToNextWordButton)

                Dim moveToPrevWordButton As NButton = New NButton("Move Caret to Prev Word")
                moveToPrevWordButton.Click += AddressOf OnMoveToPrevWordButtonClick
                stack.Add(moveToPrevWordButton)
            End If

            If True Then
                Dim groupBox As NGroupBox = New NGroupBox("Range Selection")
                groupsStack.Add(groupBox)

                Dim stack As NStackPanel = New NStackPanel()
                groupBox.Content = stack

                Dim selectCurrentParagraphButton As NButton = New NButton("Select Current Paragraph")
                selectCurrentParagraphButton.Click += AddressOf OnSelectCurrentParagraphButtonClick
                stack.Add(selectCurrentParagraphButton)

                Dim deleteSelectedTextButton As NButton = New NButton("Delete Selected Text")
                deleteSelectedTextButton.Click += AddressOf OnDeleteSelectedTextButtonClick
                stack.Add(deleteSelectedTextButton)
            End If

            If True Then
                Dim groupBox As NGroupBox = New NGroupBox("Copy / Paste")
                groupsStack.Add(groupBox)

                Dim pasteOptionsStack As NStackPanel = New NStackPanel()
                groupBox.Content = pasteOptionsStack

                If True Then
                    Dim copyButton As NButton = New NButton("Copy")
                    copyButton.Click += AddressOf OnCopyButtonClick
                    pasteOptionsStack.Add(copyButton)

                    Dim pasteButton As NButton = New NButton("Paste")
                    pasteButton.Click += AddressOf OnPasteButtonClick
                    pasteOptionsStack.Add(pasteButton)

                    Dim allowImagesCheckBox As NCheckBox = New NCheckBox("Allow Images")
                    allowImagesCheckBox.CheckedChanged += AddressOf OnAllowImagesCheckBoxCheckedChanged
                    allowImagesCheckBox.Checked = True
                    pasteOptionsStack.Add(allowImagesCheckBox)

                    Dim allowTablesCheckBox As NCheckBox = New NCheckBox("Allow Tables")
                    allowTablesCheckBox.CheckedChanged += AddressOf OnAllowTablesCheckBoxCheckedChanged
                    allowTablesCheckBox.Checked = True
                    pasteOptionsStack.Add(allowTablesCheckBox)

                    Dim allowSectionsCheckBox As NCheckBox = New NCheckBox("Allow Sections")
                    allowSectionsCheckBox.CheckedChanged += AddressOf OnAllowSectionsCheckBoxCheckedChanged
                    allowSectionsCheckBox.Checked = True
                    pasteOptionsStack.Add(allowSectionsCheckBox)
                End If
            End If

            If True Then
                Dim groupBox As NGroupBox = New NGroupBox("Inline Formatting")
                groupsStack.Add(groupBox)

                Dim stack As NStackPanel = New NStackPanel()
                groupBox.Content = stack

                Dim setBoldStyleButton As NButton = New NButton("Set Bold Style")
                setBoldStyleButton.Click += AddressOf OnSetBoldStyleButtonClick
                stack.Add(setBoldStyleButton)

                Dim setItalicStyleButton As NButton = New NButton("Set Italic Style")
                setItalicStyleButton.Click += AddressOf OnSetItalicStyleButtonClick
                stack.Add(setItalicStyleButton)

                Dim clearStyleButton As NButton = New NButton("Clear Style")
                clearStyleButton.Click += AddressOf OnClearStyleButtonClick
                stack.Add(clearStyleButton)
            End If

            Return groupsStack
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to use the selection object in order to select text as well as how to modify selected text appearance

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Rich Text Documents - Selection", "https://www.nevron.com/docs/openvision/rich-text-documents-selection.html"), ("Rich Text Range Elements", "https://www.nevron.com/docs/openvision/rich-text-range-elements.html")} End Function Private Sub PopulateRichText() Dim section As NSection = New NSection() m_RichText.Content.Sections.Add(section) section.Blocks.Add(GetDescriptionBlock("Working With the Selection Object", "The example demonstrates how to work with the selection object.", 1)) For i = 0 To 9 section.Blocks.Add(New NParagraph("Now it so happened that on one occasion the princess's golden ball did not fall into the little hand which she was holding up for it, but on to the ground beyond, and rolled straight into the water. The king's daughter followed it with her eyes, but it vanished, and the well was deep, so deep that the bottom could not be seen. At this she began to cry, and cried louder and louder, and could not be comforted. And as she thus lamented someone said to her, ""What ails you, king's daughter? You weep so that even a stone would show pity.""")) Next End Sub #End Region #Region "Implementation" #End Region #Region "Event Handlers" Private Sub OnClearStyleButtonClick(arg As NEventArgs) m_RichText.Selection.ClearFontStyleFromSelectedInlines(ENFontStyle.Bold Or ENFontStyle.Italic Or ENFontStyle.Strikethrough Or ENFontStyle.Underline) m_RichText.Focus() End Sub Private Sub OnSetItalicStyleButtonClick(arg As NEventArgs) m_RichText.Selection.AddFontStyleToSelectedInlines(ENFontStyle.Italic) m_RichText.Focus() End Sub Private Sub OnSetBoldStyleButtonClick(arg As NEventArgs) m_RichText.Selection.AddFontStyleToSelectedInlines(ENFontStyle.Bold) m_RichText.Focus() End Sub Private Sub OnPasteButtonClick(arg As NEventArgs) m_RichText.Selection.Paste() m_RichText.Focus() End Sub Private Sub OnCopyButtonClick(arg As NEventArgs) m_RichText.Selection.SelectAll() m_RichText.Selection.Copy() m_RichText.Focus() End Sub Private Sub OnDeleteSelectedTextButtonClick(arg As NEventArgs) m_RichText.Selection.Delete() m_RichText.Focus() End Sub Private Sub OnAllowTablesCheckBoxCheckedChanged(arg As NValueChangeEventArgs) m_RichText.Selection.PasteOptions.AllowTables = CType(arg.TargetNode, NCheckBox).Checked End Sub Private Sub OnAllowSectionsCheckBoxCheckedChanged(arg As NValueChangeEventArgs) m_RichText.Selection.PasteOptions.AllowSections = CType(arg.TargetNode, NCheckBox).Checked End Sub Private Sub OnAllowImagesCheckBoxCheckedChanged(arg As NValueChangeEventArgs) m_RichText.Selection.PasteOptions.AllowImages = CType(arg.TargetNode, NCheckBox).Checked End Sub Private Sub OnSelectCurrentParagraphButtonClick(arg As NEventArgs) Dim inline = m_RichText.Selection.CaretInline If inline Is Nothing Then Return Dim currentParagraph As NParagraph = TryCast(inline.ParentBlock, NParagraph) If currentParagraph IsNot Nothing Then m_RichText.Selection.SelectRange(currentParagraph.Range) End If End Sub Private Sub OnMoveToNextWordButtonClick(arg As NEventArgs) m_RichText.Selection.MoveCaret(ENCaretMoveDirection.NextWord, False) m_RichText.Focus() End Sub Private Sub OnMoveToPrevWordButtonClick(arg As NEventArgs) m_RichText.Selection.MoveCaret(ENCaretMoveDirection.PrevWord, False) m_RichText.Focus() End Sub #End Region #Region "Fields" Private m_RichText As NRichTextView #End Region #Region "Static Methods" Private Shared Function GetDescriptionParagraph(text As String) As NParagraph Return New NParagraph(text) End Function Private Shared Function GetTitleParagraphNoBorder(text As String, level As Integer) As NParagraph Dim fontSize As Double = 10 Dim fontStyle = ENFontStyle.Regular Select Case level Case 1 fontSize = 16 fontStyle = ENFontStyle.Bold Case 2 fontSize = 10 fontStyle = ENFontStyle.Bold End Select Dim paragraph As NParagraph = New NParagraph() paragraph.HorizontalAlignment = ENAlign.Left paragraph.FontSize = fontSize paragraph.FontStyle = fontStyle Dim textInline As NTextInline = New NTextInline(text) textInline.FontStyle = fontStyle textInline.FontSize = fontSize paragraph.Inlines.Add(textInline) Return paragraph End Function ''' ''' Gets a paragraph with title formatting ''' ''' ''' Private Shared Function GetTitleParagraph(text As String, level As Integer) As NParagraph Dim color = NColor.Black Dim paragraph = GetTitleParagraphNoBorder(text, level) paragraph.HorizontalAlignment = ENAlign.Left paragraph.Border = CreateLeftTagBorder(color) paragraph.BorderThickness = defaultBorderThickness Return paragraph End Function Private Shared Function GetNoteBlock(text As String, level As Integer) As NGroupBlock Dim color = NColor.Red Dim paragraph = GetTitleParagraphNoBorder("Note", level) Dim groupBlock As NGroupBlock = New NGroupBlock() groupBlock.ClearMode = ENClearMode.All groupBlock.Blocks.Add(paragraph) groupBlock.Blocks.Add(GetDescriptionParagraph(text)) groupBlock.Border = CreateLeftTagBorder(color) groupBlock.BorderThickness = defaultBorderThickness Return groupBlock End Function Private Shared Function GetDescriptionBlock(title As String, description As String, level As Integer) As NGroupBlock Dim color = NColor.Black Dim paragraph = GetTitleParagraphNoBorder(title, level) Dim groupBlock As NGroupBlock = New NGroupBlock() groupBlock.ClearMode = ENClearMode.All groupBlock.Blocks.Add(paragraph) groupBlock.Blocks.Add(GetDescriptionParagraph(description)) groupBlock.Border = CreateLeftTagBorder(color) groupBlock.BorderThickness = defaultBorderThickness Return groupBlock End Function ''' ''' Creates a left tag border with the specified border ''' ''' ''' Private Shared Function CreateLeftTagBorder(color As NColor) As NBorder Dim border As NBorder = New NBorder() border.LeftSide = New NBorderSide() border.LeftSide.Fill = New NColorFill(color) Return border End Function Private Shared Function GetLoremIpsumParagraph() As NParagraph Return New NParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum placerat in tortor nec tincidunt. Sed sagittis in sem ac auctor. Donec scelerisque molestie eros, a dictum leo fringilla eu. Vivamus porta urna non ullamcorper commodo. Nulla posuere sodales pellentesque. Donec a erat et tortor viverra euismod non et erat. Donec dictum ante eu mauris porta, eget suscipit mi ultrices. Nunc convallis adipiscing ligula, non pharetra dolor egestas at. Etiam in condimentum sapien. Praesent sagittis pulvinar metus, a posuere mauris aliquam eget.") End Function #End Region #Region "Constants" Private Shared ReadOnly defaultBorderThickness As NMargins = New NMargins(5.0, 0.0, 0.0, 0.0) #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Selection Example for WinForms Solution