Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with Switching Focus
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00344865
Message ID:
00345058
Views:
25
Hi Marcia,

Thanks for writing. The trouble I am faced with is that I want to set the focus to another control when a selection is made in a combo box. Moving the SetFocus() to the LostFocus() of the combo box would mean that the other control won't be activated until after the user moves out of the combo box.

In other words, I have several options in a combo box from which to choose. When a selection is clicked, I want another control to immediately get focus, depending on what was selected. This would mean I would need to control the transition somehow from the Valid() event. Otherwise, the other control won't get focus until after the user leaves the combo box, which could be confusing.

What I mean by confusing is that when the user clicks on another control at random, the combo box's LostFocus() event would be fired, causing the intended control to get focus, instead of where the user clicked.

Therefore, is it possible to cause another control to get focus when a selection is clicked in a combo box?

Michael Reynolds


>Hi Michael.
>
>>>However, if I happen to click anywhere else on the form itself, while the combo box is opened, I get an error saying that the setfocus command is not allowed in a valid clause. This doesn't make sense, because the setfocus command works fine from within the combo box. <<
>
>The fact that you can issue a SetFocus() from the Valid() of a combo box is the anomaly. The Valid method is used to decide if a control should be allowed to lose focus. Try switching your setFocus() from the Valid of the combo to the LostFocus(). And don't forget to add a NODEFAULT after you issue the SetFocus() when you move the code to the LostFocus method.
>
>Marcia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform