How to set multiple defaults in a list control

The other day i was trying to get a list control to have multiple items set on startup however how to do this was not immediately obvious and after searching the web it seems quite a few other were having the same issue.

Eventually I found the answer on Bruce Phillips blog, thanks a bunch Bruce!

It basically boils down to doing this.

Have a creation complete function on the application which will set the lists selected indices to an array... voila.

Example...

 


creationComplete="initApp();" width="243" height="429">


import mx.collections.ArrayCollection;

[Bindable]
public var aDemo:ArrayCollection = new ArrayCollection(
[ {label:"me", data:"me"},
{label:"you", data:"you"},
{label:"boo", data:"a dog named boo"}
]);

private function initApp():void {
//the array of selected indicies, this can be derived however you want.
var aTmp:Array = new Array(0,2);

// set the selectedindicies... and thats it
lstDemo.selectedIndices = aTmp;
}
]]>





Comments
Add New
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Help my beer fund

RocketTheme Joomla Templates