cancel
Showing results for 
Search instead for 
Did you mean: 

Dialog Box ListBox items using vbscript...

Former Member
0 Kudos

How I can add items to listbox in dialog box using vbscript?

Accepted Solutions (0)

Answers (1)

Answers (1)

marc_ledier
Active Participant
0 Kudos

Hi,

This one is tricky as you need to dynamically edit the dialog definition for that.

Once you have your CustomDialog object (created with CreateCustomDialog), you need to edit the FormDefinition attribute of the dialog.

Say for instance that you want a combo box "TypeList" with three values "Type one", "Type two" and "Type three"

For that you add in the combobox "TypeList" a unique hardcoded value "TypeListValues" (or anything you want)

In the VBS, you dynamically replace the string "TypeListValues" with the desired list, separated with \r\n. In that case "Type one\r\nType two\r\nType three"

Ex.

' create the custom dialog defined as "DialogSelectType" in your extension

set dlg = obj.CreateCustomDialog("DialogSelectType")

' get the XML form definition

set frm = dlg.FormDefinition

' keep the value for restoration

xml = frm.Value

' Replace the hard-coded value to calculated list of value

frm.Value = Replace(xml, "TypeListValues", "Type one\r\nType two\r\nType three")

if (dlg.ShowDialog()) then

   output "selected value is " & dlg.GetValue("TypeList")

end if

' restore the form definition

frm.Value = xml

' run a second time with different list

set dlg = obj.CreateCustomDialog("DialogSelectType")

set frm = dlg.FormDefinition

frm.Value = Replace(xml, "TypeListValues", "Type 4\r\nType 5\r\nType 6")

if (dlg.ShowDialog()) then

   output "selected value is " & dlg.GetValue("TypeList")

end if

frm.Value = xml

Attention that you really updated the form definition and that it will be kept until you close PowerDesigner. This is why you absolutely must restore the form definition to its initial value

Regards,

Marc