本文介绍了在MaskedTextBox中的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用MaskedTextBox中以prevent进入一个无效的IP地址,用户? (我希望它表现得就像Windows的一个)。
How can I use a MaskedTextBox to prevent the user from entering an invalid IP address? (I want it to behave just like the Windows one).
推荐答案
试试这个:
IPAddress ipAddress;
if (IPAddress.TryParse(maskedTextBoxY.Text, out ipAddress))
{
//valid ip
}
else
{
//is not valid ip
}
请注意:要使用它,你需要导入 System.Net
命名空间:
note: to use it, you need import the System.Net
namespace:
using System.Net;
这篇关于在MaskedTextBox中的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!