如何根据我在另一个下拉列表中做出的选择来填充下拉列表?

时间:2017-06-28 10:14:20

标签: drop-down-menu powerbuilder

我可以根据我在另一个下拉列表中选择的值填充下拉列表吗? 例如:我有2个下拉列表。第一个包含OptionA和OptionB。如果我选择OptionA,那么第二个下拉列表将填充value1,value2,value3。如果我在第一个下拉列表中选择OptionB,则第二个填充status1,status2,status3。

我该怎么做?谢谢!

1 个答案:

答案 0 :(得分:0)

此代码位于" SelectionChanged"我的ddlb_division对象的事件。我有2个DDLB' s,ddlb_division& ddlb_section。

int li_division_id
int li_section_id
string ls_section

SetPointer(HourGlass!)

//Clears the DDLBs
ddlb_section.Reset()

//Gets the Division ID
li_division_id = integer(Left(this.Text(index), 2))

//Cursor to gather the Sections under the selected Division
declare section cursor for
select section_id, section_name
    from tadtp_sections
    where division_id = :li_division_id;

//Open cursor
open section;

//Get first row of data
fetch section into :li_section_id, :ls_section;

//Loop while we have rows
do while(SQLCA.SQLCode = 0) 

  //Adds item to DDLB
  ddlb_section.AddItem(string(li_section_id, "00") + "     " + Trim(ls_section))

  //Gets next row
  fetch section into :li_section_id, :ls_section;

loop

//Close cursor
close section;

//Enables controls
ddlb_section.Enabled = true