Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting the Focus on a Textbox
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00585864
Message ID:
00585917
Views:
27
>Hello Everyone!!!
>I have a button Class that has New/Save and Edit/Cancel in it. I want to do the following: In the Save routine I want to set the focus to the First Textbox Object on the Form. It has A tabindex = 1. I need to do this in the class.
>Question:
>Is there a way to Set The focus of the textbox another way besides by name
>ei. THISFORM.txtCtype.Setfocus()
>
>Thanks In advance

Here is a solution, without any error checking that you may need to implement. This method stores an object reference to the textBox in a custom property of the form.

Add a custom property to your form class, call it firstFocus.

Put this code in your textBox class init() method:
* I would add checking here to make sure thisForm.firstFocus property exists
*    this is just a working example
if this.tabindex = 1  
    thisForm.firstFocus = this
endif
Add a custom method to your form class, called setFirstFocus(). Put this code in it:
* you may want to put additional checking to makesure setfocus method exists
if vartype(this.firstFocus) = "O"
    this.firstFocus.setfocus()
endif
Then, whenever you want to set focus to the first textBox (from within a form), simply call thisform.setfirstFocus().

HTH,
Steve Gibson
Previous
Reply
Map
View

Click here to load this message in the networking platform