1、需求:实现在某个容器控件中只选择某一个指定的值
2、抓取目标容器:namemapping后赋值
Set DetailProdGroups=Aliases.dbcProductsDetailContainer.DetailProdGroup
容器布局如下(每一行有checkbox,p_w_picpath,textview,label等):
3、实现思路:只抓取到容器这一层即可,然后根据child方法或者item方法(控件不同方法不一样)获取子对象,再在循环中匹配子对象的名称即可实现。
4、代码贴上:
For i =0 To DetailProdGroups.BandCount-1
'get the name of child controls
strProductName=DetailProdGroups.Child(i).ComponentTitle
'set the status of checked all false
DetailProdGroups.Child(i).BandCheckbox.Checked=false
If productname <>"" Then
'only select product "productname"
If Instr(strProductName,productname)>0 Then
DetailProdGroups.Child(i).BandCheckbox.Checked=true
End If
Else
Log.Error("The product name"& productname &" is invalid.")
Exit Sub
End If
Next
转载于:https://blog.51cto.com/alany/1570410