ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
GUI Combo Box Update
Hello.
I have a question about how to update a combo box on the GUI. For example, in my model, I have two options (A and B) for the combo box that update a global variable that effects the processes of the model. By default it shows A because A is the first choice. If I choose B, the code associated with B automatically executes the way I want it to. I run the model and it works fine. If I close the GUI, and reopen it, the combo box shows A, but the actual variable is still set to B. This said, if I run the model, it looks like it is running A but is actually running B. How can I make the combo box update its view to the currently defined variable whenever you reopen it? Also, is it possible to make an 'apply' button so the variables only update whenever I press apply? Likewise, is it possible to make a 'reset' button that resets the variables (and their displays in the combo boxes) to predefined default values? Thank you. |
#2
|
||||
|
||||
For example, in the attached image when "5" is selected for "Number of Registers Open" my model automatically shows 5 registers. If I close the Model Control GUI and open it up again, the combobox shows the default "1" for the "Number of Registers Open," but my model still shows 5 registers. Is there any way to insert a command anywhere so that when the Model Control GUI is opened again, the combobox shows the number of register in the model?
|
#3
|
|||
|
|||
One way:
1. Add an OnOpen attribute to your main GUI object. 2. Write code to determine which listed item the combobox should be pointing to in terms of its rank. For example if your combobox normally sets the value of a global variable, then OnOpen read the current value and determine which item rank in the combobox this value corresponds to. In your case you are lucky that the item value and the item rank are the same. 3. Obtain a reference to the combobox location in the GUI structure 4. Set itemcurrent attribute of the combobox 5. Call comborefresh on the combobox. In the screenshot below I show 3 different combobox locations, but I skipped step 2 and simply set all itemcurrent to the 3rd item in the list which is "c" in this case. ex. treenode combo = node("/combobox1",c); set(itemcurrent(combo),3); comborefresh(combo); In the attached model the GUI is linked to the Model Control button. Last edited by Kris Geisberger; 04-12-2011 at 11:40 PM. Reason: attached model |
The Following User Says Thank You to Kris Geisberger For This Useful Post: | ||
Chris Moon (04-13-2011) |
Thread | Thread Starter | Forum | Replies | Last Post |
update flexsim 5.10,can not save model | LINWEIXU | Q&A | 5 | 01-31-2011 07:11 AM |
Update of global variables | BenjaminBuecklein | Q&A | 4 | 11-18-2008 03:43 AM |
Update Flexsim.com | Lolke Koopmans | Marketing and Sales Information | 12 | 10-17-2008 02:09 PM |
can I use an edit box entry to update multiple labels? | KelvinHo | Q&A | 10 | 03-28-2008 07:17 AM |