net 控件库中没有为我们提供标准的IP 地址输入这个控件,只能我们自己写了
下面是我写的一个IP 地址空间(主要是改网上的后得到了,主要是改了Text 属性和添加了TextChanged 事件)
该控件继承至UserControl,下面说说该控件的界面部分
现在UserControl 上添加一个Panel控件,然后再在Panel 上添加四个TextBox 控件和三个Label 控件
将三个Label 控件的Text属性设为“
”,四个Textbox 控件的BorderStyle 属性都设为“None”,Panel 控件的BorderStyle 属性设为Fixed3D, 仔细调整个控件相互之间的位置,这样我们就可以做出IP 地址控件的外观了
其他的我就不说了,直接看代码
效果图: 主类实现部分代码: using System; using System
Collections
Generic; using System
ComponentModel; using System
Drawing; using System
Data; using System
Text; using System
RegularExpressions; using System
Windows
Forms; namespace TLControl { public partial class IPAddressBox : UserControl { [Category("属性已更改")] [Browsable(true)] public event EventHandler TextChanged ; public IPAddressBox() { InitializeComponent(); } private string _text; [Category("外观")] [D