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

Coding EVENT at runtime 1

Status
Not open for further replies.

ariftvt

Programmer
Aug 25, 2008
18
0
0
AE
I'm trying to add a code to the 'lostfocus' event of 'grid1.column4.text1' at runtime.

anybody pls help me to accomplish this..

thanks
*****************************************
Dimension cpt(1,4) && Captions
cpt(1,1)="File #"
cpt(1,2)="Name"
cpt(1,3)="Type "
cpt(1,4)="Amount "

Thisform.grid1.ColumnCount=4
For i=1 To Alen(cpt)
col_no=Alltrim(Str(i))
Capt="column&col_no"+".Header1.caption"
Thisform.grid1.&Capt=cpt(1,i)

Endfor
Thisform.grid1.column1.ReadOnly=.T.
Thisform.grid1.column2.ReadOnly=.T.
Thisform.grid1.column3.ReadOnly=.T.
Thisform.grid1.column2.Width=250

****Start lostfocus event***

&&& Help Me..

***End LostFocus Event****

mmm=SQLExec(hr_handle,"select (select emp_file from emp_master where emp_master.emp_id=pay_allowance_reg.emp_id) emp_file,"+;
"(select emp_name from emp_master where emp_master.emp_id=pay_allowance_reg.emp_id) emp_name,"+;
"(CASE WHEN allow_id=0 THEN 'OT' else case when allow_id=1 then 'Others' END END) allow_id_str,amount,"+;
"allow_id,emp_id,_month,_year,v_no FROM pay_allowance_reg "+;
"WHERE FLAGS=1 OR FLAGS=3",'Pay_entry')


If mmm>0
If Recno()>0
Thisform.grid1.RecordSource='pay_entry'

Endif
Endif

**********/////**************

 
you cannot write code at runtime, all you can do is use Bindevent and bind the lostfocus event of the textbox to an eventhandler. But also this must be written beforehand.

If you hardcode the grid to have 4 columns, you can set ColumnCount to 4 at design time too, and then you'd have a columnX.text1 box and could write code in it.

The most easiest way perhaps is creating textbox classes that have a lostfocus event code and do grid.columnx.addobject("yourtextbox") and set grid.columnx.currentcontrol = "yourtextbox".

Bye, Olaf.
 
When i throw a grid on a form directly from the dataenvironment and drill into the grid the property window of column1 or column2 does not show a lostfocus property for the column.
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
What if you had a table with predetermined code that needed to be run in memo fields and in the lost focus you called that table.

Table Stru would be something like this for a table named GRIDCONTROLDBF
Integer = PriKey - Index Primary, Memo1, Memo2, memo3,memo4

in the lost focus you had this code
Local lnUserDidWhat
lnUserDidWhat = ICASE(Code to determine what to do)

IF !USED("GRIDCONTROLDBF")
USE GRIDCONTROLDBF
ENDIF
IF INDEXSEEK(lnUserDidWhat,.t.,"GRIDCONTROLDBF","PRIKEY")
DO CASE
CASE OPtion1
DO CODE IN MEMO1
CASE option2
DO CODE in MEMO2
CASE Option3
DO CODE in MEMO3
OTHERWISE
DO CODE in MEMO4
ENDCASE
ELSE
= MessageBox("Could not figure out what to do")
ENDIF

VFP 8&9 can run code from a memo field, for versions 3-7 you will have to export the code from the memo field to a text file with a .PRG extension and run it.

David W. Grewe Dave
 
Thanks OlafDoschke
succesfully done thisway

ohandler=ThisForm.Text1
BINDEVENT(thisform.grid1.column4.text1,"lostfocus",ohandler,"dblclick")


 
DO CODE IN MEMO?
Code:
CREATE CURSOR aaa (Fld1 M)
APPEND BLANK
REPLACE Fld1 WITH "BROWSE NORMAL"
DO CODE IN Fld1

????

Maybe you mean EXECSCRIPT()?

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
white,

no, it's not the column having a lostfocus event, it's the Text1 textbox of the column, that's created with it.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top