Selecting multiple options from a list box

lional

Well-known member
Joined
Nov 29, 2018
Messages
59
Programming Experience
Beginner
Hi
I am busy writing an application for a theological college
I am writing the form where they add modules and I would like to be able to add books to each module.
What I would like to do is have a list box or combobox where the selected items be written to a database table.

I would like the user to be able to select more than one item at a time and then all of the selected items be written to the table.

I am not sure which would be the best control, combobox, list box, or if datagridview could be used

If I can just be pointed in teh direction for the correct control then I will play around with it from there

Thanks for any assistance
 
A ComboBox is for selecting a single item, so that is out. A ListBox can be made to allow only a single selection or multiple. A DataGridView will always allow multiple selection. If you only have one data point to display per item then use a ListBox. If each item has multiple data points then you'd use a DataGridView with multiple columns.

Assuming you go with a ListBox, the SelectedItems property is a collection of all the items that are selected, so you can loop through that or whatever is appropriate at the time.
 
Back
Top Bottom