O'Reilly logo

Beginning C# 7 Hands-On – The Core Language by Tom Owsiak

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

Filling ListBox using the for loop

Now we'll take our loop and fill the box. How can we accomplish this? Well, take a look.

If you had ListBox1.Items.Clear()earlier, you very likely have a method called Add here:

ListBox1.Items.Add(i);

Notice the list of methods that you can run that pops up as you type (see Figure 3.4.6). You can clear away the items in the list or you can add to them. You can put an item inside the list, then put in i and close with a semicolon:

Figure 3.4.6: Popup of the list of methods that you can run

Wait! There's an error message. If you hover your mouse over i, the message appears, as shown in the following screenshot: ...

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