搬家第41天-CITECT2018使用citectVBA显示隐藏microsoftdatagrid的列

2021-03-12 00:33

阅读:771

标签:access   datagrid   UNC   数据   WHID   end   搬家   column   初始化   

前面的练习记录了查询access数据将结果显示在microsoft datagrid控件上面,有时候需要对显示的某些列隐藏。
在画面上放置microsoft form checkbox控件,数量与datagrid中查询结果的字段数量相关,本次联系对温度1至温度4,压力1至压力4,流量1,流量2一共十个列做显示隐藏练习。checkbox控件的访问名为AN13至AN22。新建一个cicode程序,对checkbox做初始化
FUNCTION objcheckboxini()
OBJECT objcb1,objcb2,objcb3,objcb4,objcb5,objcb6,objcb7,objcb8,objcb9,objcb10
objcb1=ObjectByName("AN13")
_ObjectSetProperty(objcb1,"CAPTION","温度1")
_ObjectSetProperty(objcb1,"backcolor",15856113)
_ObjectSetProperty(objcb1,"forecolor",16711680)
 
objcb2=ObjectByName("AN14")
_ObjectSetProperty(objcb2,"CAPTION","温度2")
_ObjectSetProperty(objcb2,"backcolor",15856113)
_ObjectSetProperty(objcb2,"forecolor",16711680)
 
objcb3=ObjectByName("AN15")
_ObjectSetProperty(objcb3,"CAPTION","温度3")
_ObjectSetProperty(objcb3,"backcolor",15856113)
_ObjectSetProperty(objcb3,"forecolor",16711680)
 
objcb4=ObjectByName("AN16")
_ObjectSetProperty(objcb4,"CAPTION","温度4")
_ObjectSetProperty(objcb4,"backcolor",15856113)
_ObjectSetProperty(objcb4,"forecolor",16711680)
 
objcb5=ObjectByName("AN17")
_ObjectSetProperty(objcb5,"CAPTION","压力1")
_ObjectSetProperty(objcb5,"backcolor",15856113)
_ObjectSetProperty(objcb5,"forecolor",16711680)
 
objcb6=ObjectByName("AN18")
_ObjectSetProperty(objcb6,"CAPTION","压力2")
_ObjectSetProperty(objcb6,"backcolor",15856113)
_ObjectSetProperty(objcb6,"forecolor",16711680)
 
objcb7=ObjectByName("AN19")
_ObjectSetProperty(objcb7,"CAPTION","压力3")
_ObjectSetProperty(objcb7,"backcolor",15856113)
_ObjectSetProperty(objcb7,"forecolor",16711680)
 
objcb8=ObjectByName("AN20")
_ObjectSetProperty(objcb8,"CAPTION","压力4")
_ObjectSetProperty(objcb8,"backcolor",15856113)
_ObjectSetProperty(objcb8,"forecolor",16711680)
 
objcb9=ObjectByName("AN21")
_ObjectSetProperty(objcb9,"CAPTION","流量1")
_ObjectSetProperty(objcb9,"backcolor",15856113)
_ObjectSetProperty(objcb9,"forecolor",16711680)
 
objcb10=ObjectByName("AN22")
_ObjectSetProperty(objcb10,"CAPTION","流量2")
_ObjectSetProperty(objcb10,"backcolor",15856113)
_ObjectSetProperty(objcb10,"forecolor",16711680)
END
进入页面的事件调用这个函数,初始化也可以用citectVBA语言写。
 
新建一个citectVBA程序
Sub Showhidecolumn()
If MAIN_an13.VALUE-1 Then
main_AN4.columns(2).visible=false
Else
main_AN4.columns(2).visible=TRUE
End If
 
If MAIN_an14.VALUE-1 Then
main_AN4.columns(3).visible=false
Else
main_AN4.columns(3).visible=TRUE
End If
 
If MAIN_an15.VALUE-1 Then
main_AN4.columns(4).visible=false
Else
main_AN4.columns(4).visible=TRUE
End If
 
If MAIN_an16.VALUE-1 Then
main_AN4.columns(5).visible=false
Else
main_AN4.columns(5).visible=TRUE
End If
 
If MAIN_an17.VALUE-1 Then
main_AN4.columns(6).visible=false
Else
main_AN4.columns(6).visible=TRUE
End If
 
If MAIN_an18.VALUE-1 Then
main_AN4.columns(7).visible=false
Else
main_AN4.columns(7).visible=TRUE
End If
 
If MAIN_an19.VALUE-1 Then
main_AN4.columns(8).visible=false
Else
main_AN4.columns(8).visible=TRUE
End If
 
If MAIN_an20.VALUE-1 Then
main_AN4.columns(9).visible=false
Else
main_AN4.columns(9).visible=TRUE
End If
 
If MAIN_an21.VALUE-1 Then
main_AN4.columns(10).visible=false
Else
main_AN4.columns(10).visible=TRUE
End If
 
If MAIN_an22.VALUE-1 Then
main_AN4.columns(11).visible=false
Else
main_AN4.columns(11).visible=TRUE
End If
 
End Sub
checkbox的value属性就是看是否勾选,datagrid控件的columns序号从0开始,0和1是日期和时间,2列开始就是温度、压力、流量数据了。AN4是datagrid控件访问名,AN13至AN22是checkbox的访问名。
画面上新建一个按钮,鼠标点击事件调用这个sub

搬家第41天-CITECT2018使用citectVBA显示隐藏microsoftdatagrid的列

标签:access   datagrid   UNC   数据   WHID   end   搬家   column   初始化   

原文地址:https://www.cnblogs.com/fishingsriver/p/14514037.html


评论


亲,登录后才可以留言!