Author |
Topic |
|
SMCA
22 Posts |
Posted - 08/07/2008 : 10:34:02 AM
|
Hi there, I am currently trying to include a dynamically populated string combo box (or list box) in an x-function dialog. For this purpose, I add and populate a list box to trGetN in the before_execution function of the x-function. But I am not sure how to access this function later in the main function of the code, since no trGetN variable is supplied there. Is there any way to access dynamically generated controls of the dialog in the main function? Or, if this is not the case, can I use event handling functions to detect a change in the list box and pass the resulting value to the main function? Thanks, Stefan
OriginPro 8SR2 B0891 |
|
SMCA
22 Posts |
Posted - 08/07/2008 : 10:36:21 AM
|
Damn, mistyped part of my post and apparently cannot edit it (bug in the forum?): I was trying to say:
But I am not sure how to access this LIST BOX later in the main function of the code, since no trGetN variable is supplied there.
OriginPro 8SR2 B0891 |
|
|
Echo_Chu
China
Posts |
Posted - 08/08/2008 : 06:07:02 AM
|
Hi,
If you want to dynamically a list box and then use it in x-function body, you may need to construct it in a treenode fisst. Please refer to the link below to see how to work with a treenode
http://ocwiki.originlab.com/index.php?title=XFProgramming:Work_with_treenode
Echo OriginLab Corp
quote: Originally posted by SMCA
Hi there, I am currently trying to include a dynamically populated string combo box (or list box) in an x-function dialog. For this purpose, I add and populate a list box to trGetN in the before_execution function of the x-function. But I am not sure how to access this function later in the main function of the code, since no trGetN variable is supplied there. Is there any way to access dynamically generated controls of the dialog in the main function? Or, if this is not the case, can I use event handling functions to detect a change in the list box and pass the resulting value to the main function? Thanks, Stefan
OriginPro 8SR2 B0891
|
|
|
SMCA
22 Posts |
Posted - 08/08/2008 : 07:10:38 AM
|
Hi Echo, thanks for the reply. This was not exactly what I was looking for, although it represents a workaround that I had not thought of so far. My idea was to populate a list box as a treenode of the main x-function dialog control tree trGetN, so that the box can be seamlessly integrated into the dialog without any additional expandable tree items like in the example. Right now I am using a int combo box that I populate dynamically in the before_execution function and simultaneously populate a global array with the same indexes as the int combo box. With this I can translate the int combo box index into a string value from the array in the main function, but that approach is neither elegant nor very practical, so I thought of directly using the trGetN-structure. Best, Stefan
OriginPro 8SR2 B0891 |
|
|
Echo_Chu
China
Posts |
Posted - 08/08/2008 : 07:52:18 AM
|
Hi, Stefan
If so, you can set a string variable first such as
Name = list Label = List Box Input/Output = Input Data Type = string Data = 0 Control = a|b
Then add following code in before execute
trGetN.list.SetAttribute(STR_COMBO_ATTRIB, "|t1|t2|t3");
Echo OriginLab Corp
quote: Originally posted by SMCA
Hi Echo, thanks for the reply. This was not exactly what I was looking for, although it represents a workaround that I had not thought of so far. My idea was to populate a list box as a treenode of the main x-function dialog control tree trGetN, so that the box can be seamlessly integrated into the dialog without any additional expandable tree items like in the example. Right now I am using a int combo box that I populate dynamically in the before_execution function and simultaneously populate a global array with the same indexes as the int combo box. With this I can translate the int combo box index into a string value from the array in the main function, but that approach is neither elegant nor very practical, so I thought of directly using the trGetN-structure. Best, Stefan
OriginPro 8SR2 B0891
|
|
|
SMCA
22 Posts |
Posted - 08/08/2008 : 08:40:41 AM
|
Hi Echo, thanks a lot, that was right what I needed! A comment for those who are interested in the above example: The option string "R:0" has to be included in the x-function dialog builder. If this is not set, you will obtain an error message along the lines of "Variable value is not in predefined list, VarName = list, VarValue = t1". Best, Stefan
OriginPro 8SR2 B0891 |
|
|
|
Topic |
|
|
|