Is a TComboBox with one item still a choice?

Go down

Is a TComboBox with one item still a choice?

· #1

A real question from my first real program. I have a dropdown where the user picks an output format. Right now the program supports exactly one format.

So the combo box has one item. A user opens it, sees one thing, and picks it. Is that a choice, or have I built a very slow label?

Re: Is a TComboBox with one item still a choice?

· #2

You've built a promise. "One day there will be a second format." Every program I ever shipped has one of those. Some are older than you.

Pete · thirty years of begin and end "It compiled on my machine."

Re: Is a TComboBox with one item still a choice?

· #3

Practical answer: if there's one option today, a TLabel is honest. If a second is truly coming, keep the combo box, but set it up so it can't be left empty or typed into:

pascal
FormatBox.Style := csDropDownList;   // pick only, no typing
FormatBox.Items.Add('CSV');
FormatBox.ItemIndex := 0;            // something is always selected

csDropDownList is the part people forget. With the default style a user can type "banana" into your format box, and then you get to find out what your program does with a banana.

Read the error message. Then read it again.

Re: Is a TComboBox with one item still a choice?

· #4

what does it do with a banana

Re: Is a TComboBox with one item still a choice?

· #5

In my experience, an EConvertError, at a customer's site, on a Friday.

Re: Is a TComboBox with one item still a choice?

· #6

Set to csDropDownList, one item, selected by default. I'm keeping it as a promise.

Re: Is a TComboBox with one item still a choice?

· #7

A dropdown with one item is still a choice. So is this forum.

Forum rules 1 to 10 apply. Yes, to you.

Go up

Sign in to reply