This example demonstrates how to create a class that inherits from NComboBox and has check boxes in the combo box items.

| 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 - NCheckedComboBoxExample";
// 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()
{
NStackPanel stack = new NStackPanel();
stack.VerticalPlacement = ENVerticalPlacement.Top;
stack.HorizontalPlacement = ENHorizontalPlacement.Left;
stack.Padding = new NMargins(5);
NLabel headerLabel = new NLabel("Geography Test");
headerLabel.HorizontalPlacement = ENHorizontalPlacement.Center;
NStylePropertyEx.SetRelativeFontSize(headerLabel, ENRelativeFontSize.XXLarge); // was huge
stack.Add(headerLabel);
NLabel contentLabel = new NLabel("Place a check on the countries located in Europe and select the one whose capital is Berlin:");
NStylePropertyEx.SetRelativeFontSize(contentLabel, ENRelativeFontSize.Large); // was medium
stack.Add(contentLabel);
// Create a combo box with check boxes
NCheckedComboBox comboBox = new NCheckedComboBox();
comboBox.HorizontalPlacement = ENHorizontalPlacement.Left;
comboBox.AddCheckBoxItem("Argentina", false);
comboBox.AddCheckBoxItem("Bulgaria", true);
comboBox.AddCheckBoxItem("Canada", false);
comboBox.AddCheckBoxItem("Germany", true);
comboBox.AddCheckBoxItem("Japan", false);
comboBox.AddCheckBoxItem("Mexico", false);
comboBox.AddCheckBoxItem("Spain", true);
comboBox.AddCheckBoxItem("USA", false);
stack.Add(comboBox);
return stack;
}
public NWidget CreateExampleControls()
{
return null;
}
public string GetExampleDescription()
{
return @"
This example demonstrates how to create a class that inherits from NComboBox and has check boxes in the combo box items.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Combo Box", "https://www.nevron.com/docs/openvision/ui-combo-box.html"),
("Drop Down Edits Overview", "https://www.nevron.com/docs/openvision/ui-drop-down-edits-overview.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
#endregion
#region Fields
#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.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Class MainWindow
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Title = "NOV WPF - NCheckedComboBoxExample"
' 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)
Content = host
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
Dim stack As NStackPanel = New NStackPanel()
stack.VerticalPlacement = ENVerticalPlacement.Top
stack.HorizontalPlacement = ENHorizontalPlacement.Left
stack.Padding = New NMargins(5)
Dim headerLabel As NLabel = New NLabel("Geography Test")
headerLabel.HorizontalPlacement = ENHorizontalPlacement.Center
NStylePropertyEx.SetRelativeFontSize(headerLabel, ENRelativeFontSize.XXLarge) ' was huge
stack.Add(headerLabel)
Dim contentLabel As NLabel = New NLabel("Place a check on the countries located in Europe and select the one whose capital is Berlin:")
NStylePropertyEx.SetRelativeFontSize(contentLabel, ENRelativeFontSize.Large) ' was medium
stack.Add(contentLabel)
' Create a combo box with check boxes
Dim comboBox As NCheckedComboBox = New NCheckedComboBox()
comboBox.HorizontalPlacement = ENHorizontalPlacement.Left
comboBox.AddCheckBoxItem("Argentina", False)
comboBox.AddCheckBoxItem("Bulgaria", True)
comboBox.AddCheckBoxItem("Canada", False)
comboBox.AddCheckBoxItem("Germany", True)
comboBox.AddCheckBoxItem("Japan", False)
comboBox.AddCheckBoxItem("Mexico", False)
comboBox.AddCheckBoxItem("Spain", True)
comboBox.AddCheckBoxItem("USA", False)
stack.Add(comboBox)
Return stack
End Function
Public Function CreateExampleControls() As NWidget
Return Nothing
End Function
Public Function GetExampleDescription() As String
Return "
This example demonstrates how to create a class that inherits from NComboBox and has check boxes in the combo box items.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Combo Box", "https://www.nevron.com/docs/openvision/ui-combo-box.html"), ("Drop Down Edits Overview", "https://www.nevron.com/docs/openvision/ui-drop-down-edits-overview.html")}
End Function
#End Region
#Region "Implementation"
#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