Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing grid objects
Message
De
01/02/1999 17:53:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00182747
Message ID:
00182756
Vues:
14
>>I'm playing around with a grid on a form, with the idea that the grid and maybe the form may be incorporated in my first attempt at creating a class. At least some of what I learn will help me when creating my grid class. Here's some code I stuck in the grid's BeforeRowColChange event:
>>
>>
* frmGridTest.grdInqPost.BeforeRowColChange
>>LPARAMETERS nColIndex
>>IF THIS.Columns(nColIndex).CurrentControl.Value ;
>>		!= OLDVAL( THIS.Columns(nColIndex).ControlSource )
>>	WITH THISFORM
>>		.cmdSave.Enabled = .T.
>>		.cmdClose.Cancel = .F.
>>		.cmdCancel.Enabled = .T.
>>		.cmdCancel.Cancel = .T.
>>	ENDWITH
>>ENDIF
>>I'm trying to enable Save/Cancel buttons on my form, and switch the "Cancel" action from the form's Close button to the form's Cancel button, if the user makes a change in any value in the grid.
>>
>>Outside of telling me I should really be doing this in the valid events of the textboxes contained in the columns or something, can someone tell me how you reference the control in a column from an event in the grid? THIS.Columns(nColIndex).CurrentControl.Value is not it, I've discovered. (I've also tried a few other things.)
>
>BTW, I also tried THIS.Columns(nColIndex).Controls(things).Value, but couldn't figure out a property specifying the active control's index. I suspect that's where I need to go ...
>
>TIA,
Rich,
Hope this partial code helps :
LPARAMETERS nColIndex
llChangingRow = .f.
with this
	if lastkey() = 145 && Adding new rec
		.nLastValidRec = .nCurrec
	endif
	thisform.LockScreen = .lInGrid
	if mdown()
		lnBottom		= .top+.headerheight+.relativerow * .rowheight
		lnTop			= lnBottom - this.rowheight
		lnMouseRowPos	= mrow(wontop(),3)
		lnMouseColPos	= mcol(wontop(),3)
		llChangingRow	= !(between(lnMouseRowPos,lnTop, lnBottom) ;
		                  and between(lnMouseColPos,.left,.left+.width))
	else
		llChangingRow	= inlist(lastkey(),24,5,18,3,145,148)
	endif

	if llChangingRow 
		if !empty(.columns(nColIndex).dynamiccurrentcontrol)
			cCurrentControl = eval(.columns(nColIndex).dynamiccurrentcontrol)
		else
			cCurrentControl = .columns(nColIndex).currentcontrol
		endif
		with evaluate(".columns(nColIndex)."+cCurrentcontrol)
			.value = .value && So we can evaluate table ruleexpression
		endwith
		
		if !empty(dbgetprop(.recordsource,"Table","RuleExpression")) ;
			and !evaluate(dbgetprop(.recordsource,"Table","RuleExpression"))
			thisform.LockScreen = .F.
			wait window nowait .cWarning
			nodefault
		endif
	endif
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform