|
|
|
|
|
Introduction |
In DropDownListBoxes, the user can select the item in a list. You can fill the item
list in many ways. In this example i use an XML file containig the item list. |
| Using the code |
Run the program,use fill button to fill the ddlb.

If you want you can modify the list using XML button.

|
| Implementation |
//This function is used to find dwobjects that begin with "ddlb_".
//If it is the case i search for a file \ddlbxml\dwobjects.xml in current directory, if exists
//i use it to fill ddlb
public subroutine of_fill_ddlb_xml (datawindow arg_dw);
String ls_objects
String ls_obj[]
String ls_path
Long i
Boolean lb_dir_exists = false
ls_objects = arg_dw.Describe("DataWindow.Objects")
f_string_array( ls_objects, ls_obj[], " ")
ls_path = GetCurrentDirectory()
ls_path = ls_path + "\ddlbXml"
FOR i = 1 TO UPPERBOUND(ls_obj[])
IF (LEN( Trim(ls_obj[i])) > 5) THEN
IF LEFT(Trim(ls_obj[i]),5) = "ddlb_" THEN
f_fill_ddlb_xml( arg_dw, ls_obj[i],ls_path)
END iF
END IF
NEXT
end subroutine
//This function read the xml file and import it datastore usinf ImportFile function
subroutine f_fill_ddlb_xml (datawindow arg_dw, string arg_name, string arg_path);
DataStore dts
Long l_rows, i
INTEGER l_Idx
String ls_file_name
dts = Create datastore
//file name = arg_path + ddlb name + .xml
ls_file_name = ""
IF FileExists ( arg_path +"\" + arg_name + ".xml" ) THEN
ls_file_name = arg_path +"\" + arg_name + ".xml"
END IF
IF ls_file_name = "" THEN //Nessun file con il nome atteso
MessageBox("ERROR", "File XML not found : " + arg_path +"\" + arg_name + ".xml")
ELSE
dts.dataobject = 'dts_fill_ddlb'
dts.ImportFile(ls_file_name )
END IF
l_rows = dts.RowCount()
IF l_rows > 0 THEN
String ls_descr[]
ls_descr[] = dts.Object.descr[1,l_rows]
FOR i = 1 TO l_rows
l_Idx ++
arg_dw.SetValue(arg_name, l_Idx, ls_Descr[i])
NEXT
END IF
end subroutine
|
|
Download |
Use this Download
(PB9) |
|
|
|