Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stupid UI Tricks
Message
From
01/02/2000 14:25:12
 
 
To
01/02/2000 13:54:07
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00325732
Message ID:
00325748
Views:
25
>Hi all,
>
>Reviewing another application that is giving me heartburn. There is a trick I learned a while back that I would like to share and why it's important.
>
>When data on a form is being edited, it's a good idea to SetFocus to the first control. This may seem like a nobrainer, but if you don't do it and the user hits "Add" or "Modify" then the focus never leaves that commandbutton.
>
>A really easy way to do it is to add a custom property to your form class such as "FirstEditControl" and default it to blank. In the instances of the form class, you can fill it in with "ThisForm.txtFirstName" or whatever and then put the following code in the Add or Modify method as the last thing to do:
>IF !EMPTY(ThisForm.FirstEditControl)
>   cEditControl=ThisForm.FirstEditControl
>   &cEditControl..SetFocus()
>   &cEditControl..Refresh()
>ENDIF
My framework does almost exactly this, but I ran into a thing or two after implementing it that I had to code for- specifically, if the edited control lives on a page in a pageframe, you'll want to activate that page too:
	IF !EMPTY(THIS.FirstEditField)
		oFirstControl = EVAL(THIS.FirstEditField)
		IF TYPE("oFirstControl.Name") = "C"
			IF UPPER(oFirstControl.Parent.BaseClass) = "PAGE"
				lnPageOrder = oFirstControl.Parent.PageOrder
				oFirstControl.Parent.Parent.ActivePage = lnPageOrder
			ENDIF
			oFirstControl.SetFocus()
		ENDIF
	ENDIF
good tip.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform