O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the ListBox Control

The ComboBox is ideal for applications in space-constrained environments, but the ListBox should be used if you have enough screen space to display several options to the user at once.

The ComboBox and ListBox share almost the same exact set of properties and methods. This includes the Items collection property and the Add, Remove, and Clear methods on the Items property. For example, the following code adds strings to a ListBox control at runtime. This code is nearly identical to the code used to add string to a ComboBox control.

C#
listBox1.Items.Add("Hi");
listBox1.Items.Add("Howdy");
listBox1.Items.Add("Wuz Up");

VB
listBox1.Items.Add("Hi")
listBox1.Items.Add("Howdy")
listBox1.Items.Add("Wuz Up")

You can also add ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required