Click here to Skip to main content
Click here to Skip to main content

IP TextBox

, 8 Sep 2005
Rate this:
Please Sign up or sign in to vote.
An IP textbox control that mimics ip boxes in windows network settings


This simple IP address textbox replaces the lack of an IP box in Windows Forms control. Using the DLL you can just add the control to your toolbox and its use is very similar to a regular TextBox control.

Background (optional)

While writing an application for some end-users, i had the need for a textbox that only took an ip address and performed some validation to make sure the text entered was actually an IP. Since there was nothing readily availible that did what I wanted, I wrote a control that can easily be added to any .NET Windows Form.

Using the code

Using this control is very easy. Just right-click somewhere in your toolbox, then click "Add/Remove Items...". Now browse to the DLL, click OK and the control should now be in your toolbox. The control inherits the standard TextBox in Windows.Forms and overrides the Text property so that you can programmatically set or get the Text value as a string; I also added a method IsValid() which returns true if the Text property falls in the parameters of an actual IP address and false otherwise;

Points of Interest

The control is actually 4 TextBoxs and 3 Labels with "." placed at the appropriate locations. Most validation is done on KeyPress and currently a MessageBox pops up to alert the user of Invalid inputs such as numbers less than 0 or greater than 255.


No history yet, but thinking of being able to turn off the MessageBox warnings. There also is no validation when setting the Text programmatically and an unhandled exception is thrown.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

Comments and Discussions

GeneralMy vote of 2 Pinmemberi0018-Jan-12 13:47 
GeneralMy vote of 5 PinmemberDonaldKnuth29-Oct-11 23:45 
GeneralNeed PinmemberHardikasd25-Feb-10 2:23 
GeneralNice PinmemberMember 33287121-Dec-09 1:59 
GeneralNew code update Pinmembersysx19-Nov-09 8:33 
QuestionRegarding IP textbox Pinmemberrajionline20-Sep-07 18:55 
GeneralCheck IP Textbox if it's filled with a ip address PinmemberLuneto_HA20-Mar-07 4:38 
GeneralRe: Check IP Textbox if it's filled with a ip address Pinmemberavramik14-Jun-10 21:20 
GeneralDataBinding Pinmemberjoelthegeek1-Dec-05 6:31 
It seems that the Text property cannot be successfully databound (even after adding the Bindable attribute). It seems to have something to do with the override of Text.
Giving the Text property a different name instantly makes databinding possible.
Just rename and add
above it (and Browsable(true) if you want it in the designer).
GeneralMovement needs to be a little better Pinmemberluniv04048-Nov-05 10:26 
GeneralRe: Movement needs to be a little better Pinmemberjoelthegeek1-Dec-05 4:32 
GeneralNice Control ! A little question :doh: PinmemberFredyAlfredo20-Sep-05 3:25 
GeneralRe: Nice Control ! A little question :doh: Pinmembermawnkay27-Sep-05 5:16 
AnswerRe: Nice Control ! A little question :doh: Pinmembermawnkay4-Oct-05 5:44 
GeneralLittle changes PinmemberMansonP15-Sep-05 3:48 
GeneralRe: Little changes Pinmembermawnkay27-Sep-05 5:21 
GeneralRe: Little changes Pinmemberpinquotriot19-Mar-09 13:27 
General2 comments: PinmemberMadHatter ¢8-Sep-05 10:33 
GeneralRe: 2 comments: Pinmembermalharone8-Sep-05 16:23 
GeneralRe: 2 comments: PinmemberMadHatter ¢8-Sep-05 18:25 
GeneralRe: 2 comments: Pinmembermawnkay9-Sep-05 5:41 
GeneralRe: 2 comments: PinmemberMadHatter ¢9-Sep-05 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 8 Sep 2005
Article Copyright 2005 by mawnkay
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid