This example demonstrates how to create and configure a splitter. The splitter is a widget that splits its content area into two resizable panes, which can be interactively resized with help of a thumb located in the middle. Using the Orientation property you can specify whether the splitter is horizontal or vertical. To control how the splitter splits its content area you can use the SplitMode property.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Presentation;
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 - NSplitterExample";
// 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 splitter
m_Splitter = new NSplitter();
m_Splitter.Pane1.Content = new NLabel("Pane 1");
m_Splitter.Pane1.Padding = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
m_Splitter.Pane1.BackgroundFill = new NColorFill(NColor.LightGreen);
m_Splitter.Pane1.Border = NBorder.CreateFilledBorder(NColor.Black);
m_Splitter.Pane1.BorderThickness = new NMargins(1);
m_Splitter.Pane2.Content = new NLabel("Pane 2");
m_Splitter.Pane2.Padding = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
m_Splitter.Pane2.BackgroundFill = new NColorFill(NColor.LightBlue);
m_Splitter.Pane2.Border = NBorder.CreateFilledBorder(NColor.Black);
m_Splitter.Pane2.BorderThickness = new NMargins(1);
m_Splitter.ResizeStep = 20;
// Host it
return m_Splitter;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
// Create some splitter property editors
NList editors = NDesigner.GetDesigner(m_Splitter).CreateMemberEditors(
m_Splitter,
NSplitterBase.OrientationProperty,
NSplitterBase.ResizeWhileDraggingProperty,
NSplitterBase.ResizeStepProperty);
NStackPanel propertyStack = new NStackPanel();
for (int i = 0; i < editors.Count; i++)
{
propertyStack.Add(editors[i]);
}
stack.Add(new NGroupBox("Splitter Properties", propertyStack));
// Create splitter thumb property editors
editors = NDesigner.GetDesigner(m_Splitter.Thumb).CreateMemberEditors(
m_Splitter.Thumb,
NSplitterThumb.SplitModeProperty,
NSplitterThumb.SplitOffsetProperty,
NSplitterThumb.SplitFactorProperty,
NSplitterThumb.CollapseModeProperty
);
propertyStack = new NStackPanel();
for (int i = 0; i < editors.Count; i++)
{
propertyStack.Add(editors[i]);
}
stack.Add(new NGroupBox("Splitter Thumb Properties", propertyStack));
return new NUniSizeBoxGroup(stack);
}
public string GetExampleDescription()
{
return @"
This example demonstrates how to create and configure a splitter. The splitter is a widget that splits
its content area into two resizable panes, which can be interactively resized with help of a thumb located
in the middle. Using the Orientation property you can specify whether the splitter is horizontal or
vertical. To control how the splitter splits its content area you can use the SplitMode property.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Splitter", "https://www.nevron.com/docs/openvision/ui-splitter.html"),
("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
#endregion
#region Fields
private NSplitter m_Splitter;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Editors
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 - NSplitterExample"
' 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 splitter
m_Splitter = New NSplitter()
m_Splitter.Pane1.Content = New NLabel("Pane 1")
m_Splitter.Pane1.Padding = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)
m_Splitter.Pane1.BackgroundFill = New NColorFill(NColor.LightGreen)
m_Splitter.Pane1.Border = NBorder.CreateFilledBorder(NColor.Black)
m_Splitter.Pane1.BorderThickness = New NMargins(1)
m_Splitter.Pane2.Content = New NLabel("Pane 2")
m_Splitter.Pane2.Padding = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)
m_Splitter.Pane2.BackgroundFill = New NColorFill(NColor.LightBlue)
m_Splitter.Pane2.Border = NBorder.CreateFilledBorder(NColor.Black)
m_Splitter.Pane2.BorderThickness = New NMargins(1)
m_Splitter.ResizeStep = 20
' Host it
Return m_Splitter
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
' Create some splitter property editors
Dim editors = NDesigner.GetDesigner(m_Splitter).CreateMemberEditors(m_Splitter, NSplitterBase.OrientationProperty, NSplitterBase.ResizeWhileDraggingProperty, NSplitterBase.ResizeStepProperty)
Dim propertyStack As NStackPanel = New NStackPanel()
For i = 0 To editors.Count - 1
propertyStack.Add(editors(i))
Next
stack.Add(New NGroupBox("Splitter Properties", propertyStack))
' Create splitter thumb property editors
editors = NDesigner.GetDesigner(m_Splitter.Thumb).CreateMemberEditors(m_Splitter.Thumb, NSplitterThumb.SplitModeProperty, NSplitterThumb.SplitOffsetProperty, NSplitterThumb.SplitFactorProperty, NSplitterThumb.CollapseModeProperty)
propertyStack = New NStackPanel()
For i = 0 To editors.Count - 1
propertyStack.Add(editors(i))
Next
stack.Add(New NGroupBox("Splitter Thumb Properties", propertyStack))
Return New NUniSizeBoxGroup(stack)
End Function
Public Function GetExampleDescription() As String
Return "
This example demonstrates how to create and configure a splitter. The splitter is a widget that splits
its content area into two resizable panes, which can be interactively resized with help of a thumb located
in the middle. Using the Orientation property you can specify whether the splitter is horizontal or
vertical. To control how the splitter splits its content area you can use the SplitMode property.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Splitter", "https://www.nevron.com/docs/openvision/ui-splitter.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_Splitter As NSplitter
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class