Yes, I was going to do it with selectedLabel and selectedItem but you specifically talked about the index so I thought that was what you wanted.
--- In flexcoders@yahoogroups.com, "nehavyas13" <[EMAIL PROTECTED]> wrote: > > Thanks for your reply. > > But I guess setting selectedIndex would not work, as it is quite > possible for an extra item to be added in the data and hence the text > that was selected might now be 4th instead of 3rd. > > I think I might have to use selectedlabel and store it and then > compare that text value in dataprovider's data and then set the > selectedindex. > > But is this the standard behavious or combo box i.e it chages the > selected item as soon as the dataprovider gets a new set of data? > > > --- In flexcoders@yahoogroups.com, "valdhor" <stevedepp@> wrote: > > > > Create a variable to hold the current selection index > > > > private var comboCurrentSelectedIndex:int = -1; > > > > add a change event to the comboBox > > > > <mx:ComboBox id="myComboBox" change="myComboBoxChanged()"/> > > > > keep the selected index current > > > > private function myComboBoxChanged():void > > { > > comboCurrentSelectedIndex = myComboBox.selectedIndex; > > } > > > > When the new data comes in, set the selectedIndex of the comboBox to > > the saved index > > > > myComboBox.selectedIndex = comboCurrentSelectedIndex; > > > > > > --- In flexcoders@yahoogroups.com, "nehavyas13" <nehavyas13@> wrote: > > > > > > Hi, > > > > > > I am using a combo box and its dataprovider is an arrayCollection > > > (dp1.arr1, dp1 is a actionscript class and arr1 is a global > > > arraycollection for class). The data is refreshed every minute. Hence, > > > in the dp1 class, refreshData() method gets called every minute and > > > populates a new arraycollection arr2 with the data everytime. And then > > > lastly arr1 points to arr2. (ie. in code I write arr1=arr2). This > > > works fine. > > > > > > But the problem is say if I had selected "value 3" in combo box. Now > > > when data refreshes and arr1=arr2, the combobox shows "value 1" i.e > > > the 1st value in the array. > > > > > > What I want is the data in the combo box should be refreshed every > > > min. and also the selected value should not change. The data is bound > > > to change everytime. i.e some values might be deleted and some new > > > values might be added. > > > > > > Can somebody please provide me with an example for this or provide a > > > solution to my above problem so that the seleceted value in combo box > > > remains same? > > > > > > > > > Thanks > > > > > >