DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

combobox

Solved!
Go to solution
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
0 Kudos
Message 1 of 15
(4,884 Views)

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

http://zone.ni.com/reference/en-XX/help/370858M-01/sudref/methods/sud_method_fillitemsbyvar_tocombor...

 

There are also a lot of executable example in the help that shows how to create dialog boxes.

Winfried

0 Kudos
Message 2 of 15
(4,849 Views)

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?

 

0 Kudos
Message 3 of 15
(4,838 Views)

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

 

 

0 Kudos
Message 4 of 15
(4,825 Views)

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 :(.
0 Kudos
Message 5 of 15
(4,821 Views)

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

0 Kudos
Message 6 of 15
(4,802 Views)
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?
 
0 Kudos
Message 7 of 15
(4,799 Views)
Solution
Accepted by topic author amanda78

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

0 Kudos
Message 8 of 15
(4,795 Views)

I will try it thank you so much !

0 Kudos
Message 9 of 15
(4,792 Views)

Hello winner,

i have a question please, what do you mean by MyFoo1 and MyFoo2? 

0 Kudos
Message 10 of 15
(4,779 Views)