Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to reset a ComboBox?

Guest
Oct 07, 2009 Oct 07, 2009

I'm adding a combo box to the stage and putting a prompt on it. Once the operation on the stage is complete I'm "clearing" the selections of the user. However I can never get a combo box to clear correctly. I want to just deselect the item that was selected and add the prompt again. Here's how I'm adding it:

my_cb.prompt = "Select...";
my_cb.dataProvider = year_db;
my_cb.setStyle("embedFonts", true);

Now reseting it I've tried everything but this gives me a blank prompt:

my_cb.selectedItem = null;

my_cb.prompt = "Select...";

Thanks

TOPICS
ActionScript
926
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 07, 2009 Oct 07, 2009

The display of the prompt is dependent on the value of the selectedIndex being -1.  To reset the combobox you just need to reset the selected index to -1 and the prompt originally assigned should be restored automatically.  You should not need to reassign the prompt unless you are revising what it says.

my_cb.selectedIndex = -1;

I believe it will also work if you use selectedItem instead

Translate
LEGEND ,
Oct 07, 2009 Oct 07, 2009

The display of the prompt is dependent on the value of the selectedIndex being -1.  To reset the combobox you just need to reset the selected index to -1 and the prompt originally assigned should be restored automatically.  You should not need to reassign the prompt unless you are revising what it says.

my_cb.selectedIndex = -1;

I believe it will also work if you use selectedItem instead

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 07, 2009 Oct 07, 2009

Perfect! Very interesting they made it work that way. I like it! thanks for your help.

C

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2009 Oct 07, 2009
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines