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

how do I add click event to a programmatic control in grid? 1

Status
Not open for further replies.

DeltaWind

Programmer
Feb 14, 2003
13
US
I programmatically added a checkbox to a grid column, but I what certain actions to fire when the checbox is clicked. how do I add an interactivechange event to the checkbox ?

Any help will be appreciated. thanks.
 
Create a checkbox class and add that to your grid rather than the checkbox base class you are adding now:

Code:
DEFINE CLASS clscheckbox AS checkbox

	Height = 17
	Width = 60
	Caption = "Check1"
	Name = "clscheckbox"

	PROCEDURE InteractiveChange
		*!* Do Something Here
	ENDPROC

ENDDEFINE

boyd.gif

 
I ran into another problem.
I have added the checkbox programmatically, but now the checkbox behaves like a radio button (at least on the first couple or so clicks.
this is what I was trying to archieve.
I have two grids. one of "All items" and the other grid is "selected items". first column of the selected items is the one I have programmatically added the checkbox to. I want to be able to click on the checkbox and have the corresponding record display in the "selected items" grid. To achieve this, I put a code in the interractiveexchange method of the checkbox class. But on the first few clicks, whenever I check the first record on the checkbox and then check the second record, that action unchecks the first record. I do have sparse set to .f. in the column the checkbox is contained in. below is the code for the interactiveexchage procedure on the checkbox.

THISFORM.LockScreen = .T.
SELECT itemid ,desc1 FROM items_table INTO ;
CURSOR selectedPrds WHERE chk_add=1
IF _TALLY > 0
THISFORM.grd_selectedProds.RECORDSOURCE = "selectedPrds"
THISFORM.grd_selectedProds.VISIBLE = .T.
THISFORM.grd_selectedProds.refresh
ELSE
THISFORM.grd_selectedProds.VISIBLE = .F.
ENDIF
THISFORM.LockScreen = .f.


Why is my checkbox acting like a radio button? help.
 
DeltaWind

Is your checkbox tied to an actual logical field?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yes. The checkbox is tied to a numeric field in a read/write cursor. created with the code below.

SELECT 0 as chk_add,00 as qty,* FROM allitems;
INTO CURSOR totalItems READWRITE

chk_add is then tied to the controlsource property of the checkbox.
 
This problem is solved. I put the code in the click event as oppossed to interactivechange and it solved it.
 
spoke too soon. it still doesn't work...frustration setting in....
 
Mike has already given you the answer to your problem. For whatever reason your checkbox is not properly tied to the logical field...so when you click checkbox in the first row it changes to true because it is refreshed...then you click checkbox in second row and it finally refreshes and appears checked though the value is actually false now, which in-turn makes your first checkbox go false...

Try this...instead of tying the checkbox's controlsource to the chk_add field...tie the column that contains the checkbox to that field...

thisform.grid1.column1.controlsource = "totalitems.chk_add"

...I think you'll find that your problem is solved.

boyd.gif

 
It is the column that that is tied to the controlsource not the checkbox. I believe It would not allow you to tie the checkbox itself because the controlsource is an inherited property of the column.

My method is now only in the click event. -I have tried putting it in all events and a combination of events like gotfocuse,lostfocurse,when,valid,interactive3xchange....

It works with the click event but not exactly. if you click on a new record, it will display in the child grid, but if you unclick without leaving the same record first, it would not remove the record from the child grid unless you click on another record before the child grid is refresh....I will have to live with this bug. frustrating thought that was what interactive exchange event is supposed to handle?.
Thanks guys for your time and help.
 
Instead of:
Code:
SELECT 0 as chk_add,00 as qty,* FROM allitems;
    INTO CURSOR totalItems READWRITE
how about:
Code:
SELECT .F. as chk_add,00 as qty,* FROM allitems;
    INTO CURSOR totalItems READWRITE

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top