I’m writing a custom field for Sitecore and I want a list box. Interestingly, when I create a Lisbox() and add it to the screen, what actually appears is a combo box. Any idea if Sitecore actually provides a Listbox? And, if so, how I would set multi/single select on it (although that may become obvious to me after I get the correct control to show up)?
I am creating it like this:
Listbox lstResults = new Listbox
{
ID = GetID("lstResults"),
Multiple = false,
Width = Unit.Pixel(300),
Click = "OnSelectionChanged"
};
Sitecore doesn’t appear to have an actual listbox control, but you can either output a literal (i.e., an HTML control), or, as I did, you can use an ASP.NET ListBox control, with a little tweaking. It’s a little more work than using an ASP.NET control normally because Sitecore seems to always want to interfere with things, but it’s doable. In this case, just use the normal SelectionMode property to indicate whether to allow multi-select or not.