How to let the user add and edit items in a ComboBox? (WinForms)
In my WinForms application there is a ComboBox with default values. The user should be able to add items to the ComboBox or rename existing items.
I want the design to be simplistic. This was my initial approach:
If the user types something in to the ComboBox and hits enter and the item exists, select it. If the item does not exist, add it.
If the the ComboBox is empty when the user hits enter, delete the item at the current index.
This worked alright, except for these two problems:
Because it was a custom user interface control, the functionality is not intuitive.
If the user deletes an item from the ComboBox and there are items after it, their indices are adjusted accordingly. Basically, every item index after that item is bumped down 1. This is bad because once an item is added, its index should not be changed as other services may depend on it. Essentially, items should not be allowed to be removed. Only renamed. Possibly to blank if they are no longer needed.
The only real solution I can think of is to have a separate dialog but I cannot envision a proper design of one.
Here's an example for the first implementation one would think of:
Have a menu item open up a dialog with the purpose to add or rename items of the ComboBox.
Have a TextBox for every item in the ComboBox in this dialog window. If the last TextBox is not empty, add another one (or have a button to add another TextBox).
I suppose this approach is fine, but I don't like it for a couple reasons.
If the user has a lot of items in the ComboBox, the dialog window would be huge or require a scroll bar.
This approach requires a menu item, a corresponding dialog window, and a potential large amount of dynamic controls.
I've been trying to think of a better way to approach this but I am not having any luck.