ComboBox
Overview
Features
Sample
Settings
Description
This sample shows the basic usage of the ComboBox control.
When Case Sensitive Search is true, the user types are searched as case-sensitive
When HandleWheel is true, the user can use the mouse wheel to change the currently selected item.
The VirtualizationThreshold property allow to enable/disable the virtualization. The default value for this property is a very big number, meaning virtualization is disabled. To enable virtualization, set its value to 0 or a positive number. Note that the virtualization makes a huge difference in performance when the ComboBox contains a large number of items (say 1,000 or so).
When Case Sensitive Search is true, the user types are searched as case-sensitive
When HandleWheel is true, the user can use the mouse wheel to change the currently selected item.
The VirtualizationThreshold property allow to enable/disable the virtualization. The default value for this property is a very big number, meaning virtualization is disabled. To enable virtualization, set its value to 0 or a positive number. Note that the virtualization makes a huge difference in performance when the ComboBox contains a large number of items (say 1,000 or so).
Source
IndexController.cs
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; using System.Collections.Generic; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { private readonly ControlOptions _options = new ControlOptions { Options = new OptionDictionary { {"Case Sensitive Search",new OptionItem{ Values = new List<string> { "True", "False"}, CurrentValue = "False"}}, {"Handle Wheel",new OptionItem{ Values = new List<string> { "True", "False"}, CurrentValue = "True"}}, {"Virtualization Threshold",new OptionItem{ Values = new List<string> { "Disable" , "0" }, CurrentValue = "Disable"}} } }; private readonly C1NWindEntities _db; public ComboBoxController(C1NWindEntities db) { _db = db; } public ActionResult Index(IFormCollection collection) { _options.LoadPostData(collection); ViewBag.DemoOptions = _options; ViewBag.Countries = Countries.GetCountries(); ViewBag.Cities = Cities.GetCities(); return View(); } } }
Index.cshtml
@{ ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; List<string> countries = ViewBag.Countries; List<string> cities = ViewBag.Cities; string vThreshold = optionsModel.Options["Virtualization Threshold"].CurrentValue; } <div> <label>@Html.Raw(ComboBoxRes.Index_NonEditable)</label> <c1-combo-box selected-index="0" is-editable="false" max-drop-down-width="55" case-sensitive-search="@Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)" handle-wheel="@Convert.ToBoolean(optionsModel.Options["Handle Wheel"].CurrentValue)" virtualization-threshold="@vThreshold.Equals("Disable") ? int.MaxValue : int.Parse(vThreshold)"> <c1-items-source source-collection="@countries"></c1-items-source> </c1-combo-box> </div> <div> <label>@Html.Raw(ComboBoxRes.Index_Editable)</label> <c1-combo-box selected-index="0" is-editable="true" case-sensitive-search="@Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)" handle-wheel="@Convert.ToBoolean(optionsModel.Options["Handle Wheel"].CurrentValue)" virtualization-threshold="@vThreshold.Equals("Disable") ? int.MaxValue : int.Parse(vThreshold)"> <c1-items-source source-collection="@cities"></c1-items-source> </c1-combo-box> </div> @section Settings{ @await Html.PartialAsync("_OptionsMenu", optionsModel) } @section Description{ @Html.Raw(ComboBoxRes.Index_Text0) <br /> @Html.Raw(ComboBoxRes.CaseSensitiveSearchDescription_Text0) <br /> @Html.Raw(ComboBoxRes.HandleWheelDescription_Text0) <br /> @Html.Raw(ComboBoxRes.Index_Text1) }
Documentation