Quick update to the simple Windows Forms app

As promised, I added some extra functionality to the app, mostly tweaks or quality-of-life improvements that help make the application more user-friendly.

Here’s how it looks now:

As you can see, there are not that many differences when it comes to the UI. I’ve added a button which searches the listBox for the information you entered in the textboxes, radio buttons and checkboxes and if there is an entry with the same data, it removes it.

The arrow buttons (that’s a placeholder texture..) on the right of the listBox are used for moving an item up and down the list.

As for the code, here’s what’s changed:

Firstly, since the app needs to form strings for both the add and remove-from-text functions, I wrote a method which returns the formed string using the information from the textboxes, radio buttons, and checks. This provides much cleaner code as now, instead of writing the same thing twice, i can just call the function:


Another addition to the insertion method is if(!listBox1.Items.Contains(item) which prevents users from entering duplicates into the listBox.

The logic behind the “remove-entered” button is simple: using the formString() method we wrote earlier, we recreate the string and search for it in the listBox. If it is found, it is removed using the listBox1.Items.Remove method.

This is the code for the button that enables moving items up the list. The new methods used in this code snipplet are listBox1.Items.Insert(index, item) which inserts the item at the selected position(but does not remove it from the list) and listBox1.SetSelected(index, value) which selects the new element in order to make repeatedly pressing the button easier.

Finally, listBox1.Items.RemoveAt(index) is used for removing the copy of the item we just moved(which is situated 2 positions below the item currently selected).

The same logic is used for the moving items down the list button, except that we add instead of subtracting and the reverse, because we move the item further down the list.

Here is a link to the source code. :)