ComboBox
概要
機能
サンプル
設定
説明
このサンプルは、ComboBox コントロールの基本的な使用方法を示します。
CaseSensitiveSearch プロパティをtrueに設定した場合、検索では大文字と小文字が区別されます。
HandleWheelプロパティがtrueに設定されている場合、ユーザーがマウスホイールで現在選択されている項目を変更できます。
VirtualizationThresholdプロパティを使用すると、仮想化を有効または無効にできます。このプロパティのデフォルト値は非常に大きい数値であり、仮想化が無効になっていることを意味します。仮想化を有効にするには、値を0または正の数に設定します。ComboBoxに多数のアイテム(たとえば1,000程度)が含まれている場合に、視覚化はパフォーマンスに大きな影響を与えます。
CaseSensitiveSearch プロパティをtrueに設定した場合、検索では大文字と小文字が区別されます。
HandleWheelプロパティがtrueに設定されている場合、ユーザーがマウスホイールで現在選択されている項目を変更できます。
VirtualizationThresholdプロパティを使用すると、仮想化を有効または無効にできます。このプロパティのデフォルト値は非常に大きい数値であり、仮想化が無効になっていることを意味します。仮想化を有効にするには、値を0または正の数に設定します。ComboBoxに多数のアイテム(たとえば1,000程度)が含まれている場合に、視覚化はパフォーマンスに大きな影響を与えます。
ソース
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)
}
マニュアル