Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any way to add a valid method to a container?
Message
From
21/01/2005 17:17:21
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Novell 6.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00979025
Message ID:
00979475
Views:
26
Hi Rodd,

What I have been doing is:

In the lost focus of Textbox1 I set up an IF/ENDIF expression to test if it's valid.
If it is valid I move onto the next order of things through the tabindex. If it isn't valid, I usuallly throw up a Messagebox stating that the input was invalid, and return the focus back to the Textbox.

I think you could have something else trigger, in the case of a non valid event (such as move focus to a different control) instead of a message box?

I am uncertain if that is the "best practice". But, it seems to be quick and simple for me? Then again... it's also the only way that I know <g>.



>Thanks for the input Chad. Unfortunately, in this case, I don't want focus to leave the control if the textbox value isn't valid. If I'm understanding your scenario, invalid data could be placed in many fields and everything would be caught at save time. In my scenario, I don't want the user to leave that control until they've either left it blank or entered/selected a valid value.
>
>Thanks again for taking time to add your input though!
>
>>Rodd,
>>
>>What I do, in that type of situation, is:
>>
>>I create a new property:
>>
>>llvalid (default on the property is .F.)
>>
>>in the refresh of the Save button:
>>
>>If thisform.llvalid = .t.
>> this.enabled = .t.
>>else
>> this.enabled = .f.
>>endif
>>
>>In the textbox LostFocus event:
>>
>>if empty(thisform.textbox)
>> thisform.commandbutton.SetFocus &&Sets the focus to your button to look up valid
>>else
>> (Run a check for valid that includes a statement that makes llvalid = .t. if valid)
>>endif
>>
>>
>>Does that help?
>>
>>
>>>Hello Sergey,
>>>
>>>Sorry about the confusion. What I meant to say was that Yes, I want to allow the user to click on the button that is part of my control but No, I do not want to allow the user to click on any other buttons on the form that are NOT part of the control.
>>>
>>>In other words, if the form has 2 controls on it, 1 - a Save button that commits the changes that have been made and 2 - my control (which contains a textbox and button), the user should be allowed to click my control's button with invalid data to pop up a list of valid options but should not be allowed to press the Save button.
>>>
>>>Hope that makes more sense.
>>>
>>>Rodd
>>>
>>>>Hi Rodd,
>>>>
>>>>I'm confused. On one hand you want be able to click on button even if textbox value is invalid, on other hand you don't want that. Can you clarify?
>>>>
>>>>>I built a new control. The control is a container that contains a textbox and a button. The idea is that the button will popup a window of choices and return a value into the textbox. (I know that the same thing can be accomplished with a dropdown combo but there is a reason for what I'm wanting to do here.)
>>>>>
>>>>>However, I want the textbox to be validated before leaving the container. Initially I tried doing the validation in the LostFocus of the container but that appears to be too late. For instance, clicking on a button allows the click event to fire even if LostFocus determines that the value of the textbox is invalid.
>>>>>
>>>>>Using the valid of the textbox doesn't work because I want the user to be able to tab out of the textbox onto the control's button to be able to perform the lookup even if the text in the textbox is not valid.
>>>>>
>>>>>So, I need a Valid method on my container that fires BEFORE the container looses focus.
>>>>>
>>>>>How can I accomplish this?
>>>>>
>>>>>Thanks so much for your help!
>>>>>
>>>>>
Thanks,

Chad
Previous
Reply
Map
View

Click here to load this message in the networking platform