Actually, this is not Compact Framework question, but more OOP question...
In this case I would recomend you to consider Strategy Pattern [1] :-
provide ValidationAlgorith property for your control:
IValidation _validator = new DefaultValidator();
IValidation ValidationAlgorithm
{
set
{
_validator = value;
}
}
Then define IValidation interface in this manner:
interface IValidation
{
bool Validate(string text);
}
On LostFocus you have to write something like this:
protected override void OnLostFocus(...)
{
if (!_validator.Validate(Text)) return; // or do some action
...
}
Then somewhere in your form dynamically you may substitute validation
algorithm in this way:
yourControl.ValidationAlgorithm = new NewValidator();
HTH
[1]
http://www.dofactory.com/Patterns/PatternStrategy.aspx
--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com
Neville Lang wrote:
> I have built a custom control where I now combine the features of both a
> ComboBox and TextBox for the Compact Framework.
>
> One of the features of the TextBox is to validate user input on the TextBox
> component when it loses focus. Since this custom control can be used by a
> number of different classes, each class is likely to have a different
> validation method name. How can I pass the validation method's name to my
> custom control so that it can run that method inside the custom control when
> the TextBox component of my custom control loses focus?
>
> Further, my TextBox's LostFocus event already calls a event handler inside
> my custom control to do some other things so I want to be able to call the
> external validation method from inside that event handler.
>
> Regards,
> Neville Lang
>
>