Checked Combo Box Example for Blazor

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

Checked Combo Box Example for Blazor Description

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


Checked Combo Box Example

C# Checked Combo Box Example Code for Nevron UserInterface for Blazor
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 } }

Download a fully functional C# (.cs) Checked Combo Box Example for Blazor Solution

Related Documentation Links