The ListBox provides support to select an item or a group of item by mouse or keyboard action. There are two selection modes available in list box,
On selection of each list box item,
select
event is triggered.
To enable single selection in the list box, mode
should be set as Single
in selectionSettings
property.
<ejs-listbox id="listbox1" dataSource="@ViewBag.data">
<e-listbox-selectionSettings mode="Single"></e-listbox-selectionSettings>
</ejs-listbox>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class ListBoxController : Controller
{
public IActionResult selection()
{
ViewBag.data = new string[] { "BadmHennessey Venominton", "Bugatti Chiron", "Bugatti Veyron Super Sport", "SSC Ultimate Aero", "Koenigsegg CCR", "McLaren F1", "Aston Martin One- 77", "Jaguar XJ220" };
return View();
}
}
}
To enable multiple selection in the list box, mode
should be set as Multiple
in selectionSettings
property.
To select multiple items, use the SHIFT, CTRL, and arrow keys to make selections.
By default, the selection mode is set as
Multiple
.
<ejs-listbox id="listbox1" dataSource="@ViewBag.data">
<e-listbox-selectionSettings mode="Multiple"></e-listbox-selectionSettings>
</ejs-listbox>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class ListBoxController : Controller
{
public IActionResult selection()
{
ViewBag.data = new string[] { "BadmHennessey Venominton", "Bugatti Chiron", "Bugatti Veyron Super Sport", "SSC Ultimate Aero", "Koenigsegg CCR", "McLaren F1", "Aston Martin One- 77", "Jaguar XJ220" };
return View();
}
}
}
To select all the items in the list box,
showSelectAll
method can also be used.