Default value in Dialog Dropdown?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Default value in Dialog Dropdown?

Post by rullbandspelare » Mon Feb 06, 2017 4:12 pm

Hi!
How can i populate and show a default value in a Dialog dropdown?
I can set the items in the dropdown. But I like to have one of them preselected so that the user can just press OK if they like to use the default selection

Code: Select all

...
Let>DropVal=One%CRLF%Two%CRLF%Three
SetDialogProperty>Dialog1,MSComboBox1,ListText,%DropVal%

Show>Dialog1,res1

GetDialogProperty>Dialog1,MSComboBox1,text,TheSelection
...
Thanks!

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Default value in Dialog Dropdown?

Post by JRL » Mon Feb 06, 2017 5:11 pm

ItemIndex is zero based. In your example the following would give you "Three" for a "TheSelection" result.

Code: Select all

SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,2

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Default value in Dialog Dropdown?

Post by Marcus Tettmar » Mon Feb 06, 2017 5:16 pm

Use the ItemIndex property to set the selected index. ItemIndex is zero based:

//this sets the selected item to the first in the list.
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Default value in Dialog Dropdown?

Post by JRL » Mon Feb 06, 2017 5:52 pm

At least we gave the same answer this time. :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts