I have application form in C# and I have following code to validate IP address from masked text box:
private void MainForm_Load(object sender, EventArgs e)
{
IPAdressBox.Mask = "###.###.###.###";
IPAdressBox.ValidatingType = typeof(System.Net.IPAddress);
IPAdressBox.TypeValidationCompleted += new TypeValidationEventHandler(IPAdress_TypeValidationCompleted);
}
void IPAdress_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
{
if(!e.IsValidInput)
{
errorProvider1.SetError(this.IPAdressBox,"INVALID IP!");
}
else
{
errorProvider1.SetError(this.IPAdressBox, String.Empty);
}
}
In IPAdres_TypeValidationComleted function while if statement is true errorProvider1 blinks and give "INVALID IP" message else it should disappear. The problem is that input type seems to be always invalid even if I put valid IP adress.