ComboBox - Forum

Forum Navigation
You need to log in to create posts and topics.

ComboBox

How do I make a ComboBox (drop down menu) display a default item in the list without having to click on it?

For example: I want the PUB to read a file, or more specifically read a database field ([MyDB,MyTbl.Field1), on StartUp, get a variable that is in the ComboBox list and have the ComboBox object display that list item.

I want the ComboBox to display an item in its list at startup. Normally it will not do that.

I've tried FindItem, GetItem:

ListBoxFindItem "ComboBox5" "[MatEx.MatList.Site]" "[GetSite]"
ListBoxGetItem "ComboBox5" "[GetSite]" "[GotSite]"

I can't get it to show an item programmaticly.

@pauljonestindall

Just paste the variable into the "List of Items" field. Lines in this variable will be displayed as list items.

I already have items in the list. I want to programmatically select one of those items and it be shown in the combo box.

Think of it this way: I have a DB, someone selects a record with a field variable containing one of the items in the list. I now want that list item to show in the combo box just as if someone clicked on the list itself.

@pauljonestindall

To select an item programmatically, you must assign the value of that item to the variable listbox. Suppose you have three items in your list:

first item
second item
third item

And you need to programmatically select the second item.

Then the code would look like this:
SetVar "[ListBox1]" "second item"

@vadim

Thanks for the reply. I think I've got it figured out now. It just seems very quirky. When the program starts, what I wanted was the listbox item to be filled with matching info in the first record of a database.

Here's what I had to do to actually make it look and work properly:

If "[MatEx.MatList.Site]" "<>" ""
ListBoxFindItem "ComboBox5" "[MatEx.MatList.Site]" "[GetSite]"
ListBoxGetItem "ComboBox5" "[GetSite]" "[GotSite]"

Otherwise, at startup, the field would be blank until I clicked on at least one other record in the DB.