Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I add an item to a bound ComboBox?

Status
Not open for further replies.

spook007

Programmer
May 22, 2002
259
US
I have a ComboBox bound to a Web Service Connector and would like to have "Please select a category" as the first thing to display on my comboBox. Unfortunately after my Web Service Connector populates my comboBox the initial value I placed on my comboBox component gets wiped out.

Is there an easy way I can add my comments as my first item and not have it get wiped out?

Is there a way I can detect when the comboBox has been populated and then use addItemAt() to add my comments at the 0 index position?

Thanks
 
I've managed to use the following code to get my "Please select a category.." option in the combo box. Now I need to get the focus on the option I added and not on the first option in the list. I tried setting the selectedItem and selectedIndex to 0, but that didn't work either. Any suggestions?

on (focusIn){
if (this.length > 0){
this.addItemAt(0,"Please select a category...","N/A");
this.selectedItem(0);
}
}
 
Could you mail me the fla file, so I can help you?

tnx

LoomanMarkY@hotmail.com
 
Well... I got it figured out... I had to find a way to add my extra item after the Web Services Connector had finished populating my combo box. As soon as the movie starts, the Web Service Connector is automatically triggered. In order to add the new option I added the following code to the on (click) event of the button that takes the user to the form with the comboBox.

on (click){
//Adds instructions to comboBox Component
this._parent._parent.assistedSubject.subjectResults.cmb_subjectList.selectedItem = 0; //moves focus to first item
if (this._parent._parent.assistedSubject.subjectResults.cmb_subjectList.data != 0){
this._parent._parent.assistedSubject.subjectResults.cmb_subjectList.addItemAt(0,"Select a Broad Subject Category...",0); //adds item to list
this._parent._parent.assistedSubject.subjectResults.cmb_subjectList.selectedIndex = 0; //moves focus to first item
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top