标题:columns不是一个对象,这个问题怎么解决
只看楼主
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:323
帖 子:9621
专家分:26174
注 册:2012-2-5
得分:2 
this.setall("alignment",2,"column")&&内容居中
this.setall("alignment",2,"header")&&表头居中
this.setall("resizable",.f.,"column")&&禁止调整宽度
this.setall("movable",.f.,"column")&&禁止调整列前后
this.rowheight=28
this.Columns(1).backcolor=RGB(247,247,247)
this.Columns(1).width=290
this.Columns(2).width=30
this.Columns(3).width=30
this.Columns(4).width=30
this.Columns(5).width=30
this.Columns(6).width=30
this.Columns(7).width=30
this.Columns(8).width=30
this.Columns(9).width=30
this.Columns(10).width=30
this.Columns(11).width=30
this.Columns(12).width=30
this.Columns(13).width=30
this.Columns(14).width=30
this.Columns(15).width=30
this.Columns(16).width=30
this.Columns(17).width=30
this.Columns(18).width=30
this.Columns(19).width=30
this.Columns(20).width=30
this.Columns(21).width=30
this.Columns(22).width=30
this.Columns(23).width=30
this.Columns(24).width=30
this.Columns(25).width=30

有多少列就写多少列,不存在列的代码删除。

坚守VFP最后的阵地
2023-03-27 17:44
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:2 
以下是引用hytizj023在2023-3-27 17:39:21的发言:
报columns(1)对象无效,第一个就报

可以先看看ColumnCount是什么,这个就是Columns的元素数目。
2023-03-27 18:01
hytizj023
Rank: 1
等 级:新手上路
帖 子:166
专家分:7
注 册:2023-3-2
得分:0 
以下是引用sdta在2023-3-27 17:42:48的发言:


问题应该在
RecordSource='历史同期统计'
RecordSource='历史'
列数不同造成的

我终于弄清楚,是怎么回事了,上代码
thisform.pageframe1.page1.pageframe1.page1.grid2.setall("alignment",2,"column")&&内容居中
thisform.pageframe1.page1.pageframe1.page1.grid2.setall("alignment",2,"header")&&表头居中
thisform.pageframe1.page1.pageframe1.page1.grid2.setall("resizable",.f.,"column")&&禁止调整宽度
thisform.pageframe1.page1.pageframe1.page1.grid2.setall("movable",.f.,"column")&&禁止调整列前后
thisform.pageframe1.page1.pageframe1.page1.grid2.rowheight=28
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(1).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(2).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(3).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(4).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(5).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(6).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(7).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(8).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(9).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(10).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(11).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(12).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(13).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(14).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(15).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(16).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(17).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(18).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(19).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(20).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(21).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(22).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(23).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(24).backcolor=RGB(247,247,247)
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(25).backcolor=RGB(247,247,247)


thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(1).width=290
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(2).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(3).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(4).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(5).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(6).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(7).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(8).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(9).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(10).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(11).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(12).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(13).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(14).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(15).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(16).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(17).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(18).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(19).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(20).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(21).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(22).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(23).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(24).width=30
thisform.pageframe1.page1.pageframe1.page1.grid2.Columns(25).width=30
我把这段代码放在了查询按钮里面,就没有问题了,可能是,表格不存在,还没有生成表格前,表格的init里面当然不存在,columns,所以会报错!
2023-03-27 18:34
zhken
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:11
帖 子:273
专家分:594
注 册:2012-9-21
得分:4 
简化一下代码吧,增强可读性,看得眼花
2023-03-27 22:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-511695-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012967 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved