Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why cant a SetFocus be used in Valid method ?
Message
 
To
13/07/2002 10:53:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00658596
Message ID:
00678532
Views:
19
Rafael, thanks for your reply

>By design, you can't set focus from a valid event, but you can if you use the lostfocus event.
>

But what is the design reason for this... why cant you set focus from a valid event ?



>Example
>
>text1.valid
>***********
>
>local cAcct
>cAcct = this.value
>
>if seek(cAcct,"customers","account")
> return 1
>else
> this.value = ""
> messagebox("Account not found",16,"ERROR")
> return 0
>endif
>
>text1.lostfocus
>***************
>
>thisform.text2.setfocus
>
>
>In addition, you could add a property to the textbox text1 in its init event and give it a value,depending on whether your valid condition is met, as:
>
>text1.init
>**********
>
>this.addproperty("nCondition",0)
>
>text1.valid
>***********
>
>do case
> case (firstcondition) = .t.
> this.nCondition = 1
> return 1
> case (secondcondition) = .t.
> this.nCondition = 2
> return 1
> etc
> otherwise
> ** (error message)
> return 0
>endcase
>
>text1.lostfocus
>****************
>
>do case
> case this.nCondition = 1
> thisform.text2.setfocus
> case this.nCondition = 2
> thisform.text3.setfocus
> etc
>endcase
>
>As you can see, all you have to do is use your lostfocus event to set focus wherever you want
>
>Hope it helps
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform