ListBox

The ListBox control is used as a drop-down for the ComboBox. It shows a list and allows users to select items with the mouse or keyboard (it has a nice search as-you-type feature):

Luxembourg
Switzerland
Norway
Macao
Qatar
Ireland
United States
Singapore
Denmark
Australia
Iceland
Sweden
San Marino
Netherlands
United Kingdom
Austria
Canada
Finland
Germany
Belgium
United Arab Emirates
France
New Zealand
Israel
Japan
Brunei Darussalam
Italy
Puerto Rico
Kuwait
South Korea
Spain
The Bahamas
Bahrain
Cyprus
Malta
Taiwan
Slovenia
Saudi Arabia
Portugal
Trinidad and Tobago
Greece
Czech Republic
Estonia
Equatorial Guinea
Oman
St. Kitts and Nevis
Palau
Slovakia
Barbados
Uruguay

Selection:
Index: 0
Country: Luxembourg
GDP (US$M): 57,825
Population: 563,000

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// This file locates: "Scripts/Lesson/C1Input/ListBox.js".
c1.documentReady(function () {
    var theListBox = wijmo.Control.getControl('#theListBox');
 
    showDetail(theListBox);
    theListBox.selectedIndexChanged.addHandler(showDetail);
 
    function showDetail(s, e) {
        var template = '<b>Selection:</b><br>' +
        'Index: <b>{index}</b><br>' +
        'Country: <b>{country}</b></br>' +
        'GDP (US$M): <b>{gdp:n0}</b></br>' +
        'Population: <b>{pop:n0}</b></br>';
        var html = wijmo.format(template, {
            index: s.selectedIndex,
            country: s.selectedItem.Country,
            gdp: s.selectedItem.Gdpm,
            pop: s.selectedItem.Popk * 1000
        });
        document.getElementById('selectedItem').innerHTML = html;
    }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1InputController : Controller
    {
        // GET: ListBox
        public ActionResult ListBox()
        {
            return View(Models.Gdp.GetData());
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@model IEnumerable<Gdp>
 
<h1>
    @Html.Raw(Resources.C1Input.ListBox_Title)
</h1>
 
<p>
    @Html.Raw(Resources.C1Input.ListBox_Text1)
</p>
<div class="row demo-settings">
    <div class="col-xs-4">
        @(Html.C1().ListBox<Gdp>().Id("theListBox").Bind(Model).DisplayMemberPath("Country").Height(150))
    </div>
    <div class="col-xs-8">
        <p id="selectedItem"></p>
    </div>
</div>