Borders Example for WinForms

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

Borders Example for WinForms Description

This example demonstrates some of the static methods of NBorder that help you quickly create commonly used types of borders.


Borders Example

C# Borders Example Code for Nevron UserInterface for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
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 - NBordersExample";

			// 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 a table layout panel
            NTableFlowPanel table = new NTableFlowPanel();
            table.Padding = new NMargins(10);
            table.BackgroundFill = new NColorFill(NColor.White);
            table.MaxOrdinal = 3;
            table.HorizontalSpacing = 10;
            table.VerticalSpacing = 10;
            table.ColFillMode = ENStackFillMode.Equal;
            table.ColFitMode = ENStackFitMode.Equal;
            table.RowFitMode = ENStackFitMode.Equal;
            table.RowFillMode = ENStackFillMode.None;
            table.UniformWidths = ENUniformSize.Max;
            table.UniformHeights = ENUniformSize.Max;

            // add some predefined borders
            // 3D Borders
            NUIThemeColorMap map = new NUIThemeColorMap(ENUIThemeScheme.WindowsClassic);
            table.Add(CreateBorderedWidget("3D Border",
                NBorder.Create3DBorder(NColor.Green.Lighten().Lighten(), NColor.Green.Lighten(), NColor.Green.Darken(), NColor.Green)
            ));
            table.Add(CreateBorderedWidget("Raised Border (using Theme Colors)", 
                NBorder.CreateRaised3DBorder(map)
            ));
            table.Add(CreateBorderedWidget("Sunken Border (using Theme Colors)",
                NBorder.CreateSunken3DBorder(map)
            ));
            
            // Filled Borders
            table.Add(CreateBorderedWidget("Solid Color", 
                NBorder.CreateFilledBorder(NColor.Red)
            ));
            table.Add(CreateBorderedWidget("Solid Color With Rounded Corners", 
                NBorder.CreateFilledBorder(NColor.Blue, 10, 13)
            ));
            table.Add(CreateBorderedWidget("Gradient Filling With Outline",
                NBorder.CreateFilledBorder(NFill.CreatePredefined(ENPredefinedFillPattern.GradientVertical, NColor.Red, NColor.Blue), new NStroke(1, NColor.Green), new NStroke(1, NColor.Green))
                ));

            // Outer Outline Borders
            table.Add(CreateBorderedWidget("Outer Outline Border",
                NBorder.CreateOuterOutlineBorder(new NStroke(1, NColor.Red, ENDashStyle.Dash))
            ));
            table.Add(CreateBorderedWidget("Outer Outline Border with Rounding",
                NBorder.CreateOuterOutlineBorder(new NStroke(1, NColor.Red, ENDashStyle.Dash), 10)
            ));
            table.Add(CreateBorderedWidget("Outer Outline Border",
                NBorder.CreateOuterOutlineBorder(new NStroke(1, NColor.Red, ENDashStyle.Dash))
            ));
            table.Add(CreateBorderedWidget("Outer Outline Border with Rounding",
                NBorder.CreateOuterOutlineBorder(new NStroke(1, NColor.Red, ENDashStyle.Dash), 10)
            ));

            // Inner Outline Borders
            table.Add(CreateBorderedWidget("Inner Outline Border",
                NBorder.CreateInnerOutlineBorder(new NStroke(1, NColor.Red, ENDashStyle.Dash))
            ));
            table.Add(CreateBorderedWidget("Inner Outline Border with Rounding",
                NBorder.CreateInnerOutlineBorder(new NStroke(1, NColor.Green, ENDashStyle.Dash), 10)
            ));
            table.Add(CreateBorderedWidget("Inner Outline Border",
                NBorder.CreateInnerOutlineBorder(new NStroke(1, NColor.Green, ENDashStyle.Dash))
            ));
            table.Add(CreateBorderedWidget("Inner Outline Border with Rounding",
                NBorder.CreateInnerOutlineBorder(new NStroke(1, NColor.Green, ENDashStyle.Dash), 10)
            ));

            // Double border
            table.Add(CreateBorderedWidget("Double Border",
                NBorder.CreateDoubleBorder(NColor.Blue)
            ));

            table.Add(CreateBorderedWidget("Double Border with Two Colors",
                NBorder.CreateDoubleBorder(NColor.Blue, NColor.Red)
            ));

            table.Add(CreateBorderedWidget("Double Border with Two Colors and Rounding",
                NBorder.CreateDoubleBorder(NColor.Blue, NColor.Red, 10,  12)
            ));

            // Two color borders
            table.Add(CreateBorderedWidget("Two Colors Border",
                NBorder.CreateTwoColorBorder(NColor.Blue, NColor.Red)
            ));

            table.Add(CreateBorderedWidget("Two Colors Border with Rounding",
                NBorder.CreateTwoColorBorder(NColor.Blue, NColor.Red, 10, 12)
            ));

            // Three color borders
            table.Add(CreateBorderedWidget("Three Colors Border",
                NBorder.CreateThreeColorBorder(NColor.Red, NColor.Green, NColor.Blue)
            ));

            table.Add(CreateBorderedWidget("Three Colors Border with Rounding",
                NBorder.CreateThreeColorBorder(NColor.Red, NColor.Green, NColor.Blue, 10, 12)
            ));

            return table;
        }
        public NWidget CreateExampleControls()
        {
            return null;
        }
        public string GetExampleDescription()
        {
            return @"

This example demonstrates some of the static methods of NBorder that help you quickly create commonly used types of borders.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Borders", "https://www.nevron.com/docs/openvision/ui-borders.html"), ("Box Elements", "https://www.nevron.com/docs/openvision/ui-box-elements.html"), }; } #endregion #region Implementation /// /// Creates a simple label that demonstrates the specified border. /// /// /// /// private NWidget CreateBorderedWidget(string text, NBorder border) { NLabel label = new NLabel(text); label.HorizontalPlacement = ENHorizontalPlacement.Fit; label.VerticalPlacement = ENVerticalPlacement.Fit; label.Padding = new NMargins(10); label.Border = border; label.BorderThickness = new NMargins(5); return label; } #endregion #region Event Handlers #endregion #region Fields #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

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

VB.NET Borders Example Code for Nevron UserInterface for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
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 - NBordersExample"

        ' 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 a table layout panel
            Dim table As NTableFlowPanel = New NTableFlowPanel()
            table.Padding = New NMargins(10)
            table.BackgroundFill = New NColorFill(NColor.White)
            table.MaxOrdinal = 3
            table.HorizontalSpacing = 10
            table.VerticalSpacing = 10
            table.ColFillMode = ENStackFillMode.Equal
            table.ColFitMode = ENStackFitMode.Equal
            table.RowFitMode = ENStackFitMode.Equal
            table.RowFillMode = ENStackFillMode.None
            table.UniformWidths = ENUniformSize.Max
            table.UniformHeights = ENUniformSize.Max

            ' add some predefined borders
            ' 3D Borders
            Dim map As NUIThemeColorMap = New NUIThemeColorMap(ENUIThemeScheme.WindowsClassic)
            table.Add(Me.CreateBorderedWidget("3D Border", NBorder.Create3DBorder(NColor.Green.Lighten().Lighten(), NColor.Green.Lighten(), NColor.Green.Darken(), NColor.Green)))
            table.Add(CreateBorderedWidget("Raised Border (using Theme Colors)", NBorder.CreateRaised3DBorder(map)))
            table.Add(CreateBorderedWidget("Sunken Border (using Theme Colors)", NBorder.CreateSunken3DBorder(map)))

            ' Filled Borders
            table.Add(Me.CreateBorderedWidget("Solid Color", NBorder.CreateFilledBorder(NColor.Red)))
            table.Add(Me.CreateBorderedWidget("Solid Color With Rounded Corners", NBorder.CreateFilledBorder(NColor.Blue, 10, 13)))
            table.Add(Me.CreateBorderedWidget("Gradient Filling With Outline", NBorder.CreateFilledBorder(NFill.CreatePredefined(ENPredefinedFillPattern.GradientVertical, NColor.Red, NColor.Blue), New NStroke(1, NColor.Green), New NStroke(1, NColor.Green))))

            ' Outer Outline Borders
            table.Add(Me.CreateBorderedWidget("Outer Outline Border", NBorder.CreateOuterOutlineBorder(New NStroke(1, NColor.Red, ENDashStyle.Dash))))
            table.Add(Me.CreateBorderedWidget("Outer Outline Border with Rounding", NBorder.CreateOuterOutlineBorder(New NStroke(1, NColor.Red, ENDashStyle.Dash), 10)))
            table.Add(Me.CreateBorderedWidget("Outer Outline Border", NBorder.CreateOuterOutlineBorder(New NStroke(1, NColor.Red, ENDashStyle.Dash))))
            table.Add(Me.CreateBorderedWidget("Outer Outline Border with Rounding", NBorder.CreateOuterOutlineBorder(New NStroke(1, NColor.Red, ENDashStyle.Dash), 10)))

            ' Inner Outline Borders
            table.Add(Me.CreateBorderedWidget("Inner Outline Border", NBorder.CreateInnerOutlineBorder(New NStroke(1, NColor.Red, ENDashStyle.Dash))))
            table.Add(Me.CreateBorderedWidget("Inner Outline Border with Rounding", NBorder.CreateInnerOutlineBorder(New NStroke(1, NColor.Green, ENDashStyle.Dash), 10)))
            table.Add(Me.CreateBorderedWidget("Inner Outline Border", NBorder.CreateInnerOutlineBorder(New NStroke(1, NColor.Green, ENDashStyle.Dash))))
            table.Add(Me.CreateBorderedWidget("Inner Outline Border with Rounding", NBorder.CreateInnerOutlineBorder(New NStroke(1, NColor.Green, ENDashStyle.Dash), 10)))

            ' Double border
            table.Add(Me.CreateBorderedWidget("Double Border", NBorder.CreateDoubleBorder(NColor.Blue)))

            table.Add(Me.CreateBorderedWidget("Double Border with Two Colors", NBorder.CreateDoubleBorder(NColor.Blue, NColor.Red)))

            table.Add(Me.CreateBorderedWidget("Double Border with Two Colors and Rounding", NBorder.CreateDoubleBorder(NColor.Blue, NColor.Red, 10, 12)))

            ' Two color borders
            table.Add(Me.CreateBorderedWidget("Two Colors Border", NBorder.CreateTwoColorBorder(NColor.Blue, NColor.Red)))

            table.Add(Me.CreateBorderedWidget("Two Colors Border with Rounding", NBorder.CreateTwoColorBorder(NColor.Blue, NColor.Red, 10, 12)))

            ' Three color borders
            table.Add(Me.CreateBorderedWidget("Three Colors Border", NBorder.CreateThreeColorBorder(NColor.Red, NColor.Green, NColor.Blue)))

            table.Add(Me.CreateBorderedWidget("Three Colors Border with Rounding", NBorder.CreateThreeColorBorder(NColor.Red, NColor.Green, NColor.Blue, 10, 12)))

            Return table
        End Function
        Public Function CreateExampleControls() As NWidget
            Return Nothing
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates some of the static methods of NBorder that help you quickly create commonly used types of borders.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Borders", "https://www.nevron.com/docs/openvision/ui-borders.html"), ("Box Elements", "https://www.nevron.com/docs/openvision/ui-box-elements.html")} End Function #End Region #Region "Implementation" ''' ''' Creates a simple label that demonstrates the specified border. ''' ''' ''' ''' Private Function CreateBorderedWidget(text As String, border As NBorder) As NWidget Dim label As NLabel = New NLabel(text) label.HorizontalPlacement = ENHorizontalPlacement.Fit label.VerticalPlacement = ENVerticalPlacement.Fit label.Padding = New NMargins(10) label.Border = border label.BorderThickness = New NMargins(5) Return label End Function #End Region #Region "Event Handlers" #End Region #Region "Fields" #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

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

Related Documentation Links