grid 显示10列,要在第二列插一列,就得把剩下所有列号加一,有无简单办法?
例子:
要在第二列插一列,需要把如下每行列号全部加一,高手赐招!
.column1.header1.caption="IDNO"
.column2.header1.caption="客 户"
.column3.header1.caption="产品编号"
.column4.header1.caption="客户品号"
.column5.header1.caption="产品名称"
.column6.header1.caption="生 产 单"
.column7.header1.caption="定额"
.column8.header1.caption="计划"
.column9.header1.caption="进仓"
.column10.header1.caption="合格"
.column11.header1.caption="预计日期"
.column12.header1.caption="安排日期"
.column13.header1.caption="实际开工"
.column14.header1.caption="生产天数"
.column1.width=20
.column2.width=60
.column3.width=5
.column4.width=100
.column5.width=100
.column6.width=80
.column7.width=50
.column8.width=50
.column9.width=50
.column10.width=0
.column11.width=65
.column12.width=65
.column13.width=65
.column14.width=50
.recordsource='L22_arrange'
.column1.controlsource="l22_arrange.IDNO"
.column2.controlsource="l22_arrange.c_abbr"
.column3.controlsource="l22_arrange.part_no"
.column4.controlsource="l22_arrange.ordering_no"
.column5.controlsource='l22_arrange.chinese_name'
.column6.controlsource='l22_arrange.product_order_no'
.column7.controlsource='round(l22_arrange.quota_product,0)'
.column8.controlsource='round(l22_arrange.product_quantity,0)'
.column9.controlsource='round(l22_arrange.in_quantity,0)'
.column10.controlsource='round(l22_arrange.qc_quantity,0)'
.column11.controlsource='ttod(l22_arrange.start_date)'
.column12.controlsource='l22_arrange.arrange_date'
.column13.controlsource='ttod(l22_arrange.start_time)'
.column14.controlsource='round((l22_arrange.product_quantity-l22_arrange.in_quantity)/l22_arrange.quota_product/20,2)'
[解决办法]
对 Grid 的数据源表加列更简单。
[解决办法]
原表 有 F1,F2,F3 3个字段
Select Fl1,Recno() As NewF2,f2,f3 Into Cursor 新表名 From 原表
然后再设 新表名 为 Grid 的数据源。
[解决办法]
新增列加到最后,然后调整显示到第二列即可
nn = Thisform.grid1.ColumnCount + 1
Thisform.grid1.ColumnCount = nn
With Thisform.grid1.Columns(nn)
.ControlSource = 'l22_arrange.xxx'
.ColumnOrder = 2
Endwith
[解决办法]
MYFORM = NEWOBJECT("C_FORM")MYFORM.SHOWREAD EVENTSRETURN DEFINE CLASS C_FORM AS FORM AUTOCENTER=.T. CAPTION="表格中插入列示例" ADD OBJECT GRID1 AS GRID WITH TOP=((THISFORM.HEIGHT-THISFORM.GRID1.HEIGHT)/2)+20,LEFT=(THISFORM.WIDTH-THISFORM.GRID1.WIDTH)/2 ADD OBJECT COMMAND1 AS COMMANDBUTTON WITH CAPTION="添加新列",TOP=6,LEFT=THISFORM.GRID1.LEFT,HEIGHT=28,BUTTONCOUNT=2,AUTOSIZE=.T. PROCEDURE COMMAND1.CLICK SELECT 内容,RECNO() AS 新列,A1,A2,A3,A4 FROM TABNAME INTO CURSOR TABNAME_INS THISFORM.GRID1.COLUMNCOUNT=FCOUNT("TABNAME_INS") THISFORM.GRID1.RECORDSOURCE="TABNAME_INS" THISFORM.COMMAND1.ENABLED=.F. THISFORM.COMMAND1.CAPTION="添加成功" ENDPROC PROCEDURE GRID1.INIT CREATE CURSOR TABNAME (内容 C(4),A1 N(4),A2 N(4),A3 N(4),A4 N(4)) INSERT INTO TABNAME VALUES ("A",15,16,17,18) INSERT INTO TABNAME VALUES ("B",20,21,22,23) GO TOP WITH THIS .FONTSIZE=10 .HEADERHEIGHT=28 .RECORDSOURCETYPE = 1 .RECORDSOURCE = "TABNAME" .ROWHEIGHT=24 FOR I = 1 TO .COLUMNCOUNT WITH .COLUMNS(I).HEADER1 .ALIGNMENT=2 ENDWITH ENDFOR ENDWITH ENDPROC PROCEDURE DESTROY CLEAR EVENTS ENDPROCENDDEFINE