Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which methods to use for a listbox?
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01104865
Message ID:
01104952
Views:
14
>As Cetin said, whether or not you need the code in all of these events really depends on what specific code is in them. Also an don't forget the OOP axiom that events call methods. If you decide to class these controls it would be beneficial to have the InteractiveChange event call a method like;
>
>
>* List InteractiveChange
>RETURN This.ValueChange()
>
>
>Then add a ValueChange method and put the actual code in there. The big plus of this is that it becomes very easy to have the same behavior result from different events. For example having the InteractiveChange and ProgrammiticChange events execute the same behavior.
>
>The ProgrammaticChange is often overlooked until soemthing happens that causes an unexpected behavior.

Thanks, Jim.

Here is click method (I've added WAIT WINDOW for testing purpose)
LOCAL luRetVal
WAIT WINDOW TIMEOUT 1 "Click"
luRetVal = DODEFAULT()
IF !EMPTY(this.value)
	thisform.refreshpagedata(this.name)
ENDIF	
RETURN luRetVal
InteractiveChange method
LOCAL luRetVal
WAIT WINDOW TIMEOUT 1 "Interactive Change"
luRetVal = DODEFAULT()
lcValue = this.Value
*thisform.Caption = lcValue
IF !EMPTY(this.value)
	thisform.refreshpagedata(this.name)
ENDIF	
RETURN luRetVal
LostFocus
LOCAL luRetVal
WAIT WINDOW TIMEOUT 1 "Lost Focus"
luRetVal = DODEFAULT()
thisform.enabledprevnext() 
IF !EMPTY(this.value)
	thisform.refreshpagedata(this.name)
ENDIF	
RETURN luRetVal
Key Press
LPARAMETERS nKeyCode, nShiftAltCtrl
WAIT WINDOW TIMEOUT 1 "Key Press"
IF m.nKeyCode = 13 OR m.nKeyCode = 9
	NODEFAULT	
	thisform.SetFocuToPage1(1)
ELSE 
    DODEFAULT(nKeyCode, nShiftAltCtrl)
ENDIF
The first control is actually a combobox, but 4 rest controls are listboxes. The listboxes have very similar code in them.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform