View previous topic :: View next topic |
Author |
Message |
keesp Guest
|
Posted: Wed Oct 05, 2005 12:47 pm Post subject: using the ValidateText method of UniversalTextBox |
|
|
Hi,
I am using the ValidateText method of UniversalTextBox, but am not very happy with the popup boxes that are shown. I would preferably carry out the validation, and if the result is false perform a CancelTextEntrry, while setting the foreground colour of the text in a different colour (or so).
Is there any way to achive this functionality? Does ValidateText perform an intelligent check, or is it quite simple to program? Is there any way to prevent the popup box from showing?
Thanks,
Kees |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Oct 05, 2005 11:29 pm Post subject: |
|
|
To handle exceptions that occur during Text->Value conversion yourself you can either handle the ValidateTextError event or override the OnValidateTextError method and set the Handled property to true (this will prevent the message box being shown). _________________ Infralution Support |
|
Back to top |
|
|
keesp Guest
|
Posted: Thu Oct 06, 2005 8:15 am Post subject: popup boxes |
|
|
Hi,
Overriding the OnValidateTextError does *not* prevent the popup box from showing up. I am working with the following setting; overriding the following methods of universal edit box:
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnLostFocus(EventArgs e)
{
if( this.ValidateText() == false )
this.CancelTextEntry();
this.FormatText();
base.OnLostFocus(e);
}
protected override void OnValidateTextError(Infralution.Controls.ValidateTextErrorEventArgs args)
{
//base.OnValidateTextError (args);
}
The OnLostFocus is used to store the entered text values when someone clicks the mouse on another position on virtual tree.
What happens is, that I now can leave the edit box and that the values are taken over, whether they are correct or not, but when I re-enter the edit box, suddenly the popup-box is shown (six times) before being able to edit again.
I have sent a zip file that demonstrates the problem.
Thanks
Kees |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Oct 06, 2005 12:24 pm Post subject: |
|
|
Just overriding OnValidateTextError is not enough - you must set the Handled property of the args parameter to true - eg
Code: |
protected override void OnValidateTextError(Infralution.Controls.ValidateTextErrorEventArgs args)
{
args.Handled = true;
}
|
_________________ Infralution Support |
|
Back to top |
|
|
keesp Guest
|
Posted: Thu Oct 06, 2005 1:46 pm Post subject: Works Fine! Thanks |
|
|
See subject |
|
Back to top |
|
|
|