Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
7 captures
29 Jan 2009 - 06 Mar 2012
OctJANMar
Previous capture05Next capture
200920122013
success
fail
COLLECTED BY
Organization:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
Collection:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20120105193525/http://www.codeproject.com:80/KB/edit/IPAddressControl.aspx
Click here to Skip to main content
8,386,176 members and growing!
EmailPassword Lost password?
Home
Search within:




Licence CPOL
First Posted 18 Aug 2008
Views 11,577
Downloads 391
Bookmarked 12 times

Textbox Which Holds an IP Address - Take 2

Byjkatebin | 18 Aug 2008
This control mimics the standard IP address textbox you see in Windows. It has four sections, separated by a period, each of which contains numbers which are >= 0 and <= 255.
 
See Also
Print Article
add
Add to your CodeProject bookmarks
Discuss
Discuss this article
3
  2.50 (5 votes)
1 vote, 20.0%
1
1 vote, 20.0%
2
1 vote, 20.0%
3
2 votes, 40.0%
4

5
2.50/5 - 5 votes
μ 2.50, σa 2.28 [?]
Sponsored Links

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...

License

This article, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL)

About the Author

jkatebin



United States United States

Member


loading...
Sign Up to vote  PoorExcellent
Add a reason or comment to your vote:x
Votes of 3 or less require a comment

Comments and Discussions

 
 RefreshFirstPrevNext
GeneralMade simple changememberChuck G14:42 4 May '10  
GeneralRe: Made simple changememberChuck G18:59 4 May '10  
GeneralIt's ok!memberMorlack_x0:54 22 Oct '09  
Last Visit: 19:00 31 Dec '99     Last Update: 9:35 5 Jan '121

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

Permalink |Advertise |Privacy |Mobile
Web03 |2.5.120104.1 |Last Updated 18 Aug 2008
Article Copyright 2008 by jkatebin
Everything elseCopyright ©CodeProject, 1999-2012
Terms of Use
Layout:fixed|fluid

The Daily Insider

[8]ページ先頭

©2009-2025 Movatter.jp