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 MvcExplorer.Models; using System.Collections.Generic; using System.Web.Mvc; namespace MvcExplorer.Controllers { public partial class ComboBoxController : Controller { private readonly ControlOptions _optionModel = 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"}} } }; public ActionResult Index(FormCollection collection) { IValueProvider data = collection; _optionModel.LoadPostData(data); ViewBag.DemoOptions = _optionModel; ViewBag.Countries = Countries.GetCountries(); ViewBag.Cities = Cities.GetCities(); return View(); } } }
Index.cshtml
@{ List<string> countries = ViewBag.Countries; List<string> cities = ViewBag.Cities; ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; string vThreshold = optionsModel.Options["Virtualization Threshold"].CurrentValue; } <div> <label>@Html.Raw(Resources.ComboBox.Index_NonEditable)</label> @(Html.C1().ComboBox().Bind(countries) .SelectedIndex(0).IsEditable(false) .CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)) .HandleWheel(Convert.ToBoolean(optionsModel.Options["Handle Wheel"].CurrentValue)) .VirtualizationThreshold(vThreshold.Equals("Disable") ? int.MaxValue : int.Parse(vThreshold))) </div> <div> <label>@Html.Raw(Resources.ComboBox.Index_Editable)</label> @(Html.C1().ComboBox().Bind(cities) .SelectedIndex(0).IsEditable(true) .CaseSensitiveSearch(Convert.ToBoolean(optionsModel.Options["Case Sensitive Search"].CurrentValue)) .HandleWheel(Convert.ToBoolean(optionsModel.Options["Handle Wheel"].CurrentValue)) .VirtualizationThreshold(vThreshold.Equals("Disable") ? int.MaxValue : int.Parse(vThreshold))) </div> @section Settings{ @Html.Partial("_OptionsMenu", optionsModel) } @section Description{ @Html.Raw(Resources.ComboBox.Index_Text0) <br /> @Html.Raw(Resources.ComboBox.CaseSensitiveSearchDescription_Text0) <br /> @Html.Raw(Resources.ComboBox.HandleWheelDescription_Text0) <br /> @Html.Raw(Resources.ComboBox.Index_Text1) }
Documentation