I am looking for a TextBox control, which can validate and filter out IP Address. After a bit research, I come with this https://social.msdn.microsoft.com/Forums/vstudio/en-US/4c2aefae-ca6a-4e71-8564-fe73da7107f1/maskedtextbox-formatting-for-an-ip-address?forum=csharpgeneral. It’s easy to implement and simple to use. Just like normal TextBox.
using System.Windows.Forms;
class IPTextBox : TextBox
{
public IPTextBox() : base()
{
SetStyle(ControlStyles.ResizeRedraw, true);
}
protected override CreateParams CreateParams
{
get
{
var cp = base.CreateParams;
cp.ClassName = "SysIPAddress32";
return cp;
}
}
}
Another complete solution can be found http://www.sanity-free.org/127/an_ipaddress_control_the_win32_sysipaddress32_control_in_csharp.html