Giving the user the flexibility to remove items they're not going to use in a list box control can make your VB.NET application more user-friendly. In VB, you can use the "Items" property to add, remove, or obtain a reference to the items in the list box control. The "SelectedIndex" property gives you the index of the currently selected item. The "RemoveAt" method will remove the currently selected item from the list box.
- Skill level:
- Moderately Easy
Other People Are Reading
Launch Microsoft Visual Basic Express, click "New Project..." on the left pane of your screen and double-click "Windows Forms Application" to start a new project.
Double-click "ListBox" on the Toolbox pane to add a new list box control. Add a button by double-clicking "Button" on the toolbox.
Double-click the form to create a form load event and add the following code to add three items to the list box:
Double-click "Button1" to create a click event for the button. Type the following code to remove the selected item when the button is clicked:
Press "F5" to run the program. Select an item from the list box. Click "Button1" to remove it.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for