Skip to main content
Known Participant
September 1, 2017
Question

AS2: How to prevent ComboBox displaying item 0 in the dropdown list

  • September 1, 2017
  • 1 reply
  • 966 views

Hello there!

I'm looking for a workaround preventing a ComboBox displaying item #0 in the dropdown list.

Example:

Items in the CB:

"Choose...", "" (#0, appears as selectedItem at start)

"label 1", "data 1"

"label 2", "data 2"

"label 3", "data 3"

When clicked, the CB displays the four items in the dropdown list.

That's bad!

I just want it to display in the dropdown list:

"label 1", "data 1"

"label 2", "data 2"

"label 3", "data 3"

Repeating item #0 in the the dropdown list is annoying and useless.

I thank you in advance for your help!!!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
September 2, 2017

i don't know why you're including something you don't want to display but you can also use the selectedIndex property of your combobox to display whatever you want.

Germaris1Author
Known Participant
September 2, 2017

Hello kglad !

Thanks for replying.

Years ago you have helped me so many times... (my username was "Germaris").

Good to read from you again.

Thought I was clear in my first post...

Let me elaborate and explain:

I must indicate to users the purpose of my CB: "Choose...". Right?

I must include this item (index 0). I have no choice.

So, when the user clicks he knows what he/she is doing.

The dropdown list appears and "Choose..." is repeated in the list!!! Why?

I dont want "Choose..." to be repeated.

I previously said it is annoying and useless.

The displayed list must begin with item 1 (index 1).

I made several attempts and amongst them some using the selectedIndex property with no results.

kglad
Community Expert
Community Expert
September 2, 2017

one way (among many) to do this would be to use the removeItemAt(0) when your combobox opens and addItemAt(0) (if nothing is selected and you want that 'choose' to redisplay).