Copy link to clipboard
Copied
Hi all !
How to programmatically select item in the ListBox by item index?
listbox1.selection.index=1 - not worked
Works for me. I also as save the user's last choice so the next time the dialog is used the default may not be 1.
Here is what I user in some of my scripts.

| dlg.msgPnl.grp5a =dlg.msgPnl.add('group'); | |
| dlg.msgPnl.grp5a.orientation='row'; | |
| dlg.msgPnl.grp5a.alignment='fill'; | |
| dlg.msgPnl.grp5a.st1 = dlg.msgPnl.grp5a.add('statictext',undefined,'Name Stamp Text Location:'); | |
| var position =['Top Left','Top Center','Top Right','Center Left','Center','Center Right','Bottom Left','Bottom Center','Bottom Right']; | |
| d |
Copy link to clipboard
Copied
Works for me. I also as save the user's last choice so the next time the dialog is used the default may not be 1.
Here is what I user in some of my scripts.

| dlg.msgPnl.grp5a =dlg.msgPnl.add('group'); | |
| dlg.msgPnl.grp5a.orientation='row'; | |
| dlg.msgPnl.grp5a.alignment='fill'; | |
| dlg.msgPnl.grp5a.st1 = dlg.msgPnl.grp5a.add('statictext',undefined,'Name Stamp Text Location:'); | |
| var position =['Top Left','Top Center','Top Right','Center Left','Center','Center Right','Bottom Left','Bottom Center','Bottom Right']; | |
| dlg.msgPnl.grp5a.dd1 = dlg.msgPnl.grp5a.add('dropdownlist',undefined,position); | |
| dlg.msgPnl.grp5a.dd1.selection=textLocationDefault; |
| dlg.msgPnl.grp6a =dlg.msgPnl.add('group'); | ||
| dlg.msgPnl.grp6a.orientation='row'; | ||
| dlg.msgPnl.grp6a.alignment='fill'; | ||
| dlg.msgPnl.grp6a.st1 = dlg.msgPnl.grp6a.add('statictext',undefined,'Font'); | ||
| fontlist = new Array(); | ||
| for (var i=0,len=app.fonts.length;i<len;i++) { | ||
| fontlist = app.fonts.name; | ||
| } | ||
| dlg.msgPnl.grp6a.dd1 = dlg.msgPnl.grp6a.add('dropdownlist',undefined,fontlist); | ||
| dlg.msgPnl.grp6a.dd1.selection=1; |
| dlg.msgPnl.grp7a =dlg.msgPnl.add('group'); | |
| dlg.msgPnl.grp7a.orientation='row'; | |
| dlg.msgPnl.grp7a.alignment='fill'; | |
| dlg.msgPnl.grp7a.st1 = dlg.msgPnl.grp7a.add('statictext',undefined,'Text Layer Style: '); | |
| dlg.msgPnl.grp7a.dd1 = dlg.msgPnl.grp7a.add('dropdownlist',undefined,textStyleList); | |
| dlg.msgPnl.grp7a.dd1.preferredSize.width = 160; | |
| dlg.msgPnl.grp7a.dd1.selection=textStyleDefault; |
| dlg.msgPnl.grp8a =dlg.msgPnl.add('group'); | |
| dlg.msgPnl.grp8a.orientation='row'; | |
| dlg.msgPnl.grp8a.alignment='fill'; | |
| dlg.msgPnl.grp8a.st1 = dlg.msgPnl.grp8a.add('statictext',undefined,'Image Layer Style:'); | |
| dlg.msgPnl.grp8a.dd1 = dlg.msgPnl.grp8a.add('dropdownlist',undefined,imageStyleList); | |
| dlg.msgPnl.grp8a.dd1.preferredSize.width = 160; | |
| dlg.msgPnl.grp8a.dd1.selection=imageStyleDefault; |
Copy link to clipboard
Copied
yes.. listBox.selection.index =1
Find more inspiration, events, and resources on the new Adobe Community
Explore Now