Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unknow member or unable to edit control of grid's column on page frame

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
Hi all,
I've one grid created on second page of page frame and linked to .PRG file for each time activate on different page. Under Activate events, each grid's column defined its own member class created under .PRG file.The problem is I couldn't able to access to each member control of grid's columns even I tried to change it but it will remain same class created under individual page's activate events.
I won't initialise the gird's column control base class on grid's init event because I need to set additive access to different .PRG file When access on different page. This problem of failed to
access column member or control of grid won't be exists in form when I initalised grid's member control under grid's init events. BTW,i'm using vfp 6.

My Code under Page item Activate Events
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

Hopefully anyone could solve my problem here.Thanks!
 
I think I've ready found the solution, the reason why it unable detect button(control members fo grid) because it is created right after return focus to main form when you have grid created on page frame.

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

Struggle me for one day more until i could find out the reason and solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top