Introduction
This is a control which represents a single IP address. It uses .NET 3.0, and is built with the Visual Studio 2008 IDE (if you want to open the.sln file).
Background
Nothing too amazing, I just got sick of users always messing up when entering an IP address. I didn't see anything out there using theMasktextbox
control that comes with .NET, so I thought I'd throw something together to help 'em out. I had attempted this before, and more people were interested than I thought would be. Hopefully, this (second) version is a little more stable...
Using the Code
This is extremely simple. Get and set the text as you normally would (pass it "192.168.0.100" and you'll get the same thing back, even if it is displayed differently). Do this via theIP
andText
properties. Otherwise, use it as you would normally use a control.
To add this to your project, either copy the source, or add a reference to the DLL. The namespace isSEG.Controls
. If you're into it, you can add it to your toolbox in Visual Studio and just drag/drop it onto your form.
You can change the min/max for each octet by changing theOctetValueMIN
andOctetValueMAX
values. The only reason I can think of that you'd want to change this is if you are trying to get a mask vs. an IP...
Listen for the IP address changes via theIPAddressChanged
event.
privatevoid OnTextChanged(object sender, EventArgs e){ TextBox tb = (senderas TextBox);if (senderis SEG.Controls.IPAddressControl) _config.Mail.SMTPServer = ipac.Text;
Also, if you right click, you get the option to resolve a hostname. This is useful since most users don't understand the concept of IP address, but do know computer names.

Points of Interest
Might be nice to put in an enum to mod the min/max internally (enum { Mask, IP, Custom}); might prevent invalid address entry and keep things tighter. Haven't tested this much, let me know of any bugs you find...
History
Replacement for my original post which was more of an experimental control. However, people actually seemed to use it as is, hence the upgrade...