How to use a text file to populate a ComboBox

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

How to use a text file to populate a ComboBox

Post by gchichester » Wed Oct 21, 2015 6:15 pm

I have 8 different scripts that use the same large 200+ list of items in a ComboBox, I've been maintaining manually.
There must be a way to maintain just a single file and use it in my ComboBoxes.
I found the "ListText" properties for the ComboBox and added the full path of the file I want to use.
I'm lacking the knowledge of what and where to modify my code.
I did search the forum and found a few posts, but none were detailed enough.
If anyone knows of any articles or videos that relate to this issue please forward them.
Thank you in advance for all your help
Gil

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

Re: How to use a text file to populate a ComboBox

Post by Marcus Tettmar » Thu Oct 22, 2015 10:58 am

ListText needs a string, with each item separated by line breaks, so all you need to do is read the text file into a string and add that to ListText:

ReadFile>c:\bla\items.txt,strTheItems
SetDialogProperty>Dialog1,Combo1,ListText,strTheItems
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: How to use a text file to populate a ComboBox

Post by gchichester » Fri Oct 30, 2015 11:40 am

Marcus,
I had a few issue of where the code was added, but figured it out.

Thanks for your input

Gil
Thank you in advance for all your help
Gil

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