请教,如何在 grid1中给一列绑上不同图片。
请教,如何在 grid1中给一列绑上不同图片。有3张图,名称分别是 yes.bmp no.bmp none.bmp ,grid表格列中加入了一个图片控件(picture),表格对应数据表有一列用于存放图片名称,图片不显示出来序号 设备名称 合格情况 图片
1 eqpt001 合格 yes.bmp
2 eqpt002 不合格 no.bmp
3 eqpt003 未检 none.bmp
程序代码:
DEFINE CLASS grid1 as Grid
left=10
top=40
width=200
RowHeight=32
HeaderHeight=0
GridLines=0
DeleteMark=.f.
RecordMark=.f.
AllowCellSelection=.f.
SplitBar=.f.
ScrollBars=2
icoIndex = 1
PROCEDURE init
this.AddObject("imgCol","Column1")
this.imgCol.ColumnOrder = 1
ENDPROC
PROCEDURE AfterRowColChange(nColIndex)
IF this.RowColChange == 1
this.icoIndex = RECNO()
this.SetFocus
ENDIF
ENDPROC
ENDDEFINE
DEFINE CLASS Column1 as Column
Width=32
Sparse=.F.
Visible=.t.
PROCEDURE init
this.RemoveObject("Text1")
this.AddObject("img0", "image")
this.AddObject("img1", "image")
this.img0.Picture = "d:\temp\test_0.ico"
this.img1.Picture = "d:\temp\test_1.ico"
* 切换 Column 的 CurrentControl
this.DynamicCurrentControl = [IIF(RECNO("tt")==thisform.grd.icoIndex,"img0","img1")]
ENDPROC
ENDDEFINE
[此贴子已经被作者于2026-5-29 15:28编辑过]
[此贴子已经被作者于2026-5-30 09:54编辑过]