我在页面框架的第二页上创建了一个网格,并且每次在不同页面上激活时链接到.PRG文件。在Activate事件下,每个网格的列定义了自己在.PRG文件下创建的成员类。问题是我无法访问网格列的每个成员控件,即使我尝试更改但它将保持在单个页面的激活事件下创建的同一类。
我不会在网格的init事件上初始化网格列控制基类,因为我需要设置对不同.PRG文件的附加访问权限。当访问不同的页面时。当我在网格的初始事件下初始化网格成员控制时,这种无法访问列成员或网格控制的问题不会以形式存在。顺便说一下,我正在使用vfp 6。
页面项目下的我的代码激活事件
set procedure to
set procedure to cn_pro additive
for count = thisform.page_.pages(thisform.page_.activepage).grid_list.columncount to 1 step -1
column_ = "column" + alltrim(str(count))
thisform.page_.pages( thisform.page_.activepage ).grid_list.removeobject( "&column_")
next
with thisform.page_.pages(thisform.page_.activepage).grid_list
.addobject("column1","column")
.columns(1).visible = .t.
.columns(1).bound = .t.
.columns(1).width = 75
.columns(1).header1.alignment = 2
.columns(1).header1.caption = "Mod_Qty"
.columns(1).removeobject("text1")
.columns(1).addobject("btn_qty","btn_quan")
.columns(1).currentcontrol = "btn_qty"
.columns(1).btn_qty.visible = .t.
.columns(1).btn_qty.caption = "Mod Qty"
.columns(1).sparse = .f.
endwith
create cursor tmpcur(btn_qty logical null)
use in select('tmpcur')
use in dbf('tmpcur') in 0 again alias tmpcur_
use in tmpcur
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = ""
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = "tmpcur_"
thisform.page_.pages(thisform.page_.activepage).grid_list.refresh()
**My class code in cn_pro.PRG file(Same example 1 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages( frm_.page_.activepage ).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.column1.btn_qty.enabled = .f.
**=>It will return Error message said "unknown member btn_qty" How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
**My class code in cn_pro.PRG file(Same example 2 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages(frm_.page_.activepage).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.removeobject('column1')
**=>Remove entire column1 contained with** commandbutton "btn_qty"
.createobject('column1','column')
.column1.bound = .t.
.column1.text1.visible = .t.
.column1.sparse = .f.
.refresh()
**=> Previous CommandButton on column1 should be changed and
** replace with text here but It won't change and still be
** same commandbutton.Why, How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
希望有人能在这里解决我的问题。谢谢!
答案 0 :(得分:0)
如果我理解正确,你的方法将无效。您不需要删除列,您需要向列添加/删除对象,然后将列的当前控件属性设置为您想要的控件。
如果要为同一列显示各种不同的控件,则将dynamiccurrentcontrol属性设置为将查看值的表达式,然后返回要依赖于其显示的column.control的名称。表达式中的逻辑比较。
答案 1 :(得分:0)
我认为我已经准备好找到解决方案,之所以无法检测按钮(控制成员网格),因为它是在页面框架上创建网格后将焦点返回到主窗体后立即创建的。
m.result = .t.
frm_.page_.pages(frm_.page_.activepage).btn_print.setfocus() =>to set it focus for later trigger btn_print's gotfocus
=>event,which will be able to change property's of member control of grids.
this.release =>exit "frm" class
Coding for btn_print gotfocus
if m.result=.t.
m.result = .f.
with this.parent.gid_list
.columns(1).btn_qty.enabled = .f.
endwith
endif
在我找到原因和解决方案之前,再奋斗一天。