on 01-07-2016 3:53 AM
How I can add items to listbox in dialog box using vbscript?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.