请在复选框中提供帮助 [英] Please help in Checklistbox
问题描述
问候!
当前在两个复选框中起作用,一个是区域chklistbox 1和子区域chklistbox2.
当我检查chklistbox1的一个或两个区域时,我成功填充了chklistbox 1的区域,所有子区域都将填充在子区域复选框2中.我也设法做到这一点.但是我现在的问题是当我取消选中所选区域时.我需要删除与该区域相关的所有子区域.
以下是我的代码.
非常感谢和需要您的所有帮助.
Greetings!
currently working in two checklistbox one is Area chklistbox 1 and sub area chklistbox 2.
i successfully popoulate the area from chklistbox 1 when i check one or two area from chklistbox1 all the sub area will populate in the sub area checklistbox 2. Which i also manage to do it. However my problem now is when i unchecked the selected Area. i need to remove all the sub areas related to that area.
below are my codes.
Your all help is greatly appreciated and needed.
Sub ListSubArea
Dim rs,sql, i, j, areaname
for i = 0 to chklistarea.Items.Count-1
If chklistarea.Checked(i) = True then
'chklistsubarea.items(j) = chklistarea.Checked(i)
areaname = chklistarea.Items(i)
End if
Next
set rs=createobject("adodb.recordset")
sql = "SELECT * FROM v_area_subarea where c_area_name ='"& arename &"' order by c_sub_area_name"
openrs rs,sql
chklistsubarea.Clear
if not rs.eof then
do
chklistsubarea.Items.Add rs.Fields("c_sub_area_name").Value
rs.movenext
loop until rs.eof
End if
rs.close
End Sub
推荐答案
您已经这样做了.下面的代码将删除子区域"复选框列表中的所有项目.
You already doing it. Below code will remove all the items in the Sub Area checkbox list.
chklistsubarea.Clear()
快速提问:
.NET具有非常强大的数据库概念(ADO.NET),但是您仍然使用ADODB吗?
Quick Question:
.NET has a very powerful DB concepts (ADO.NET), but you still using ADODB?
谢谢您的答复.实际上,我正在使用的应用程序是SalesLogix,而后端代码的方法类似于vb代码.我需要做的是删除仅与checklistbox1相关的chklistbox2中的数据.请帮忙.您的意见将不胜感激.谢谢
hi thank you for your reply. actually the application that I''m using is SalesLogix and the back-end side the approach code is similar to vb code. What i need to do is Remove the data in chklistbox2 that is only related to checklistbox1. please help. your inputs will highly appreciated. thanks
使用以下代码完成了它的工作::)
Done it''s working now using below codes: :)
Sub ListSubArea
dim rs
dim sql
dim i
dim areaname
areaname = ""
chklistmainagent.Clear
for i = 0 to chklistarea.Items.Count-1
If chklistarea.Checked(i) = True then
areaname = Areaname & "''" & chklistarea.Items(i) & "'',"
End if
Next
if areaname <> "" then
areaname = left(areaname,len(areaname)-1)
Else
chklistsubarea.Clear
Exit sub
End if
set rs=createobject("adodb.recordset")
sql = "SELECT * FROM v_area_subarea where c_area_name in ("& areaname &") order by c_sub_area_name"
openrs rs,sql
chklistsubarea.Clear
if not rs.eof then
do
chklistsubarea.Items.Add rs.Fields("c_sub_area_name").Value
rs.movenext
loop until rs.eof
End if
rs.close
End Sub
这篇关于请在复选框中提供帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!