Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Valid after LostFocus - possible to simulate
Message
De
07/03/2002 13:49:23
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00629752
Message ID:
00629773
Vues:
13
From MADDITEM within REFRESH, which is called from within VALID thusly...

MADDITEM method
lparameter lcItem
local lnLen, lnWidth
with This
	lnLen   = alen(.aList, 1) + 1
	lnWidth = alen(.aList, 2)
	if lnWidth = 0
		dimension .aList[lnLen]
		.aList[lnLen] = lcItem
	else
		dimension .aList[lnLen, lnWidth]
		.aList[lnLen, 1] = lcItem
	endif
	.mFillColumns(lnLen)
	if .lUpdateRowSource
		This.mUpdateRowSource(lcItem)
	endif
	if alen(.aList, 1) > 1
		=asort(.aList)
	endif
	.Requery()
endwith
REFRESH method
LPARAMETERS llCalledFromValid
local lnResult, lcOldValue, lcAlias
with This
	lnResult   = 1
	lcOldValue = ""
	lcAlias    = .cSourceAlias
	if !empty(lcAlias) and used(lcAlias)
		if recno(lcAlias) <> .nRecord
			lcOldValue = eval(.ControlSource)
			.nRecord   = recno(lcAlias)
		else
			lcOldValue = .DisplayValue
		endif
	else
		lcOldValue = .DisplayValue
	endif
	if !empty(lcOldValue)
		lnResult = ascan(.aList, lcOldValue)
	endif
	if lnResult = 0
		.mAddItem(lcOldValue)
	endif
*!*		.DisplayValue = lcOldValue
*!*		.Value = lcOldValue
	if llCalledFromValid
		.Value = m.lcOldValue
	else
		if .parent.BaseClass=="Column"
			.parent.ControlSource=.parent.ControlSource
		else
			.ControlSource=.ControlSource
		endif
	endif
endwith
VALID method
local llRetVal
llRetVal = This.Refresh(.t.)
if not llRetVal
	return 0
endif
>Where the MUPDATEROWSOURCE method is called from?
>
>>>>Is it possible to trigger a control's VALID event from the control's LOSTFOCUS event, and if so what is an example of the syntax?
>>>>
>>>>TIA
>>>
>>>Why do you want to do that? If you want to keep user in the field issue
* Lostfocus
>>>This.SetFocus()
>>>NODEFAULT
>>
>>I'm updating a combo Quick Books style, and from within the cbo class I ask the user if they really want to add a new item to the lookup tale.
>>
>>If they don't, I want focus to stay on the cbo class.
>>
>>The following code is from the MUPDATEROWSOURCE method...
>>************************************************************
>>
>>lparameter tcItem
>>if type("tcItem") = "U" .or. type("tcItem") = "L" .or. empty(tcitem)
>>	return .f.
>>endif	
>>local lcAlias, lcField, lnSelect
>>lcAlias = alltrim(This.cRowSourceAlias)
>>lcField = alltrim(This.cRowSourceField)
>>if empty(lcAlias) or empty(lcField)
>>	return .f.
>>endif
>>if not used(lcAlias)
>>	use (lcAlias) again in 0
>>endif
>>if not This.mValidateField()
>>	return .f.
>>endif
>>lnSelect = select()
>>_callingrec = RECNO()
>>select (lcAlias)
>>
>>* this will check to see if there is an index tag to see if item exists, and use it
>>* otherwise a LOCATE will be used.
>>FOR nCount = 1 TO 254
>>   IF !EMPTY(TAG(nCount))  && Checks for tags in the index
>>      * ? CDX(nCount)     && Display .CDX names
>>		IF UPPER(TAG(nCount)) = UPPER(lcField)		
>>			tagexists = .t.
>>			EXIT
>>		ENDIF
>>   ELSE
>>   	  tagexists = .f.
>>      EXIT  && Exit the loop when no more tags are found
>>   ENDIF
>>ENDFOR
>>* IF UPPER(TAG(nCount)) = UPPER(lcField)
>>IF tagexists
>>	SET ORDER TO (lcField)
>>	SEEK ALLTRIM(UPPER(tcItem))
>>ELSE
>>	locate for alltrim(upper(lcField)) == alltrim(upper(tcItem))
>>ENDIF
>>
>>	
>>if eof(lcAlias)
>>
>> 	if this.yesno("Add new record/value to "+alltrim(lcAlias)+"list?")
>>		
>> 		APPEND BLANK
>> 		replace (lcField) WITH (tcItem)
>>		* insert into (lcAlias) ( (lcField) ) values ( tcItem )
>>*!*			IF CURSORGETPROP("Buffering")>1
>>*!*			  =tableupdate(.t.)
>>*!*			endif
>>		* browse
>>		if len(ALLTRIM(this.formadd)) > 4
>>			* SELECT (lcalias)
>>			IF this.formparam = .f.
>>				do form (this.formadd)
>>			ELSE
>>				DO FORM (this.formadd) WITH ALLTRIM(UPPER(tcItem))
>>			ENDIF
>>		endif
>>		this.Requery()
>>	else
>>		this.setfocus()
>>	endif
>>endif
>>select (lnSelect)
>>GOTO _callingrec
>>return eof(lcAlias)
>>
>>**************************************************************
>>If I do This.SetFocus I get an error 'Cannot call SetFocus from valid, rangehigh... etc.'
On a CLEAR day you can see forever.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform