描述:如图所示,一个下拉框跟一个列表框
在选择下拉框的时候,判断列表框中是否存在在下拉框中当前选中的这个值,如果没有就添加进去!
有则弹出对话框,提示列表框中已经存在这个值!
大家可以用这个练练手!
先附上问题代码:
- namespace 控件测试A
- //定义默认空间
- function bool start_click()
- //这里添加你要执行的代码
- return true
- //函数返回语句
- endfunction
- function bool exit_click()
- //这里添加你要执行的代码
- help.exit()
- return true
- //函数返回语句
- endfunction
- function bool ce()
- int b,c,n=0
- string a
- b=combo.getcursel("ComboBox0")
- a=combo.gettextbycur("ComboBox0",b)
- c=list.getcount("list0")
- if(c==0)
- list.addstring("list0",a)
- else
- while(n<c)
- if(str.strcompare(list.gettext("list0",n),a)==0)
- help.messagebox("已经选择")
- return true
- else
- list.addstring("list0",a)
- return true
- endif
- n=n+1
- endwhile
- endif
- //list.addstring("list0",a)
- return true
- endfunction
- function bool ComboBox0_selectchanged()
- //这里添加你要执行的代码
- int c
- c=thread.beginthread("控件测试A.ce")
- return true
- endfunction
- endnamespace
- //大家可以看看他代码有什么问题!
- //然后附上我写的
- 空间 dddd
- //定义默认空间
- 功能 逻辑型 开始_点击()
- //这里添加你要执行的代码
- 返回 真
- //函数返回语句
- 功能结束
- 功能 逻辑型 退出_点击()
- //这里添加你要执行的代码
- 辅助.退出()
- 返回 真
- //函数返回语句
- 功能结束
- 功能 逻辑型 下拉框0_选择改变()
- //这里添加你要执行的代码
- string a = combo.gettextbycur("下拉框0",combo.getcursel("下拉框0"))
- int i=0
- int j=list.getcount("列表框0")
- while(i<j)
- if(str.strcompare(a,list.gettext("列表框0",i))==0)
- help.messagebox("已经存在")
- return true
- endif
- i=i+1
- endwhile
- list.addstring("列表框0",a)
- 返回 真
- 功能结束
- 空间结束
- //空间结束语句
复制代码
|