05-30-2017 08:20 AM
Hello everyone
I need to put in the combobox of a dialog that I create two choices, but I do
not know how to proceed? Do I have to set variables in the script? If yes can
you tell me how to write the script? thank you
Solved! Go to Solution.
05-31-2017 01:53 AM
Hi amanda78,
There are several ways to fill a combobox. You create a combobox in the dialog editor.
In the editor you could the click ListItems in the property window and add your items.
You could also do it in a script. See the help for details: http://zone.ni.com/reference/en-XX/help/370858M-01/sudref/methods/sud_method_items_tocombort/
or
There are also a lot of executable example in the help that shows how to create dialog boxes.
Winfried
06-01-2017 02:11 AM
Hi winner,
Thank you so much for your reply, I put two elements in the listitems, now
I would like to attribute to each element its script that suits, I
activated for the combobox: eventMouseDown, for the following I do
not know how to write the condition On these two elements. Do you
have an idea please?
06-01-2017 03:24 AM
Hi amanda78
If you have a dialog box with a combobox and a button you can try this script:
Sub Button1_EventClick(ByRef This)
Select case ComboBox1.Selection
Case 1
Call Msgbox("Value1 selected")
Case 2
Call Msgbox("Value2 selected")
End Select
End Sub
Sub ComboBox1_EventChange(ByRef This)
Call Button1.RunClick
End Sub
Sub ComboBox1_EventInitialize(ByRef This)
Call This.Items.Add("Value1", 1)
Call This.Items.Add("Value2", 2)
This.SelectionExt = 1
End Sub
This shows a messagebox when you change the selection in the combobox (ComboBox1_EventChange) or when you click the button (Button1_EventClick).
Winfried
06-01-2017 04:09 AM
Hi winner,
Thank you very much for your help. well, as you can see in the attached
picture, I have a combobox that contains two elements, we choose an element
and then we click on the OK button. By cons for each element I have a different
script, that mean if i choose the element 1 it executes the script1 and if i
choose the element 2 we run the script2. But I do not know where I have to
introduce the scripts? I am a little lost because I am a beginner in the use
of diadem :(.
06-01-2017 05:46 AM
Hi amanda78
If you are a beginner I would suggest that you take a traning at NI for DIAdem or at least that you have a look at the procedure in the help. There are several topics in Precedures>Creating User Dialog Boxes.
If you are in the layout mode you have an Events tab on the rigth. Select the object and then click the ... Button an the corresponding event. With STRG-E you could switch between the code view and the layout view. You could not simply copy the code in that editor, but first create the funktion by clicking on the event name on the right and than paste the content of the code in the created code snipped.
Hope that helps
Winfried
06-01-2017 06:07 AM
Hi winner,
Thank you for your answer, Yes I created the event but since
I have two different codes (for each element of the combobox), I do not know how
to do? shall i put them both in one function with a condition?
06-01-2017 06:24 AM
Hi amanda78
That depends on you code. If it is very simple code you could replace the MsgBox with your code. But most time it is better to put them into seperate procedures:
Sub Button1_EventClick(ByRef This)
Select case ComboBox1.Selection
Case 1
Call MyFoo1
Case 2
Call MyFoo2
End Select
End Sub
Sub ComboBox1_EventChange(ByRef This)
Call Button1.RunClick
End Sub
Sub ComboBox1_EventInitialize(ByRef This)
Call This.Items.Add("Value1", 1)
Call This.Items.Add("Value2", 2)
This.SelectionExt = 1
End Sub
Sub MyFoo1
Call MsgBox ("Foo1")
End Sub
Sub MyFoo2
Call MsgBox ("Foo2")
End Sub
Winfried
06-01-2017 06:32 AM
I will try it thank you so much !
06-02-2017 02:14 AM
Hello winner,
i have a question please, what do you mean by MyFoo1 and MyFoo2?