What is the best way to create controls for a list of items?

Cynolycus 285 Reputation points
2026-07-23T08:01:09.4933333+00:00

I am using VB.net and trying to create a windows forms application, part of which will display a list comprised of items from two groups.

I have 2 groups of items.

The first group contains 87 items and the second group contains around 20 items, which may increase as time goes on.

Each item has it's own individual image.

On the main form the user will have 2 options for the main group, 1. Select all items or 2. The minimum items.

From the second group they will be able to choose 2 or 3 pre-set options.

This is then used to create a tab on a tab control showing only the needed items.

My idea is to create one single list that contains all selected items.

Have the list sorted alphabetically.

Then populate the labels and picture boxes from the sorted list.

Apart from how long it's been since I last created any program, my problem is that I only have a basic understanding of .net and don't know what would be the best way to achieve this.

If it were just a list of items I wouldn't have a problem, just create a list, add the selected items from both groups to the list, sort the new list, then iterate through the new list while creating the labels and adding the text to each.

Usually I( have the controls already on the form, but to do this I need to create them, or at least assign values to them when the program is running.

So how do I do it to include the images, and make sure the images are shown next to the appropriate labels.

Is it done by using a single list, a list of items and a list of images with matching IDs, an array, or something else, and how would the sorting be done, because if I recall correctly not all can be sorted.

Could somebody point me in the right direction please.

Developer technologies | VB
0 comments No comments

1 answer

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 5,185 Reputation points Microsoft External Staff
    2026-07-24T09:57:00.76+00:00

    Thank you for reaching out.

    For this scenario, we recommend creating a single data object that contains both the item's name and its associated image. After the user selects the required items from the two groups, those items can be combined into a single collection and sorted alphabetically.

    This approach keeps the item name and image together, ensuring that the correct image remains associated with the correct item even after sorting. It also simplifies dynamically creating the required labels and picture boxes when the tab is generated.

    If you plan to reuse the same layout for multiple items, you may also consider creating a custom UserControl containing a Label and PictureBox, and then creating one instance for each item in the sorted collection.

    Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.