在VFP表格Grid中如何恢复移去的列?

来源:百度知道 编辑:UC知道 时间:2024/09/24 04:55:57
由于数据库字段个数太多,想在GRID表格中随意显示或隐藏列,我添加了复选框,并写上代码:
if this.value=1
thisform.grid1.addobject("column3")
else
thisform.grid1.removeobject("column3")
endif
对第二个语句可在表格使第3列不显示,但用第一个语句却不能恢复显示第3列。请问如何写好第一个语句?
象在Excel中隐藏列再取消隐藏列。即thisform.grid1.removeobject("column3") 的逆操作。
谢谢这位朋友的回答,但没有完全达到我的要求,我是想将这一列的数据和单元格都要去掉或恢复,而这位朋友的回答,只能隐藏数据不能移去单元格.我用这个方法:
if this.value=1
thisform.grid1.column3.width=80
else
thisform.grid1.column3.width=0
endif
可象Excel那样可隐藏和恢复,但在隐藏处出现比较大的垂直阴影,还是不太理想。
谢谢第二位朋友的回答,效果与第一位朋友的回答一样,单元格没有移去。

利用column的visible属性,不要移除。

if this.value=1
thisform.grid1.column3.visible=.T.
else
thisform.grid1.column3.visible=.F.
endif

同意QAtlantis,不过你可以更简单

thisform.grid1.column3.visible = (this.value = 1)

意思就是当选中是, 就是Show, 否则就是Hide