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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to pick checkbox properly in grid

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
I've manual pick problem for those checkbox layout in grid's first columns where there are all created in class object.

I'm able to picked success on first row, but it won't be appear when click on second row.

check box in entire column seem to be failed in random picked and unable to pick in identical for each row.


Coding :
define class chk_sel as checkbox
name = "chk_sel"

procedure init

this.value = 0
this.caption = ""
this.readonly = .f.
this.tabstop = .f.

endproc

enddefine

Define class frmpurc As Form

procedure init

For each frm in _screen.Forms
if frm.name == "MyForm"
select "" as pick,supcode,item_desc,inv_no,po_no,line,acc_qty, ;
taxcode,acc_amt,net_tax,gros_amt from purc ;
into cursor tmpcur ;
where alltrim(inv_no) = alltrim(this.txt_search.value)

If NOT USED('tmpcur_')
USE DBF("tmpcur") in 0 AGAIN alias tmpcur_
else
USE IN 'tmpcur_'
USE DBF("tmpcur") in 0 AGAIN alias tmpcur_
endif

sele tmpcur_

frm.grid_list.recordsource = SPACE(0)
frm.grid_list.recordsource = "tmpcur_"
frm.grid_list.deletemark = .f.
frm.grid_list.readonly = .f.

frm.grid_list.column1.width = 25
frm.grid_list.column1.bound = .f.
frm.grid_list.column1.controlsource = "tmpcur_.pick"
frm.grid_list.column1.readonly = .f.

frm.grid_list.column1.text1.visible = .t.
frm.grid_list.column1.removeobject("text1")
frm.grid_list.column1.addobject("pick","chk_sel")

frm.grid_list.column1.currentcontrol = "pick"
frm.grid_list.column1.pick.visible = .t.
frm.grid_list.column1.pick.readonly = .f.
frm.grid_list.column1.pick.tabstop = .t.
frm.grid_list.column1.sparse = .f.


endif
endfor

endpro

enddefine


Thanks anyone could help me to solve this.
 
I'm thinking that you need to check the 'sparse' property for a checkbox in a grid.
It needs to be set to .t. (non-default)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I would change the order of things you do, eg first set recordsource space(0), then use the table, then add and set currentcontrol, then set recordsource, and finally set controlsource.
And yes, for a checkbox in each row sparse has to be .F., .t. means sparse, and you only sparsely will see the current control then, just in the active row, so in that aspect I don't second Griff.

Bye, Olaf.
 
Did someone delete my post... I just said derr, you are right Mike, sorry

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I always do it through the UI, so I guess the builder does it automatically?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Thanks to all your reply and I ready able to fixed it by modify 2 coding place to allow each checkbox bound to each row but not field.

If NOT USED('tmpcur_')
USE DBF("tmpcur") in 0 AGAIN alias tmpcur_
else
USE IN select('tmpcur_') /* Change it from USE IN 'tmpcur' * /
USE DBF("tmpcur") in 0 AGAIN alias tmpcur_
endif

frm.grid_list.column1.bound = .t. /* Change it from .f. */
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top