IPBoxControl 开发手记(二)

    如果哪位发现什么问题和bug,请多多指出,我会及时修改。谢谢!

ExpandedBlockStart.gif ContractedBlock.gif /**/ /*
InBlock.gif * Purpose: IPAddress TextBox Control.
InBlock.gif * Author: Vincent
InBlock.gif * Date: 2004-10-29
InBlock.gif *
ExpandedBlockEnd.gif 
*/

None.gif
None.gif
using  System;
None.gif
using  System.Windows.Forms;
None.gif
None.gif
namespace  Sci.Vincent.Controls
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// IP Address Box Control.
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class IPBox : System.Windows.Forms.UserControl
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private System.Windows.Forms.TextBox textBox1;
InBlock.gif        
private System.Windows.Forms.Label label1;
InBlock.gif        
private System.Windows.Forms.Label label2;
InBlock.gif        
private System.Windows.Forms.TextBox textBox2;
InBlock.gif        
private System.Windows.Forms.Label label3;
InBlock.gif        
private System.Windows.Forms.TextBox textBox3;
InBlock.gif        
private System.Windows.Forms.TextBox textBox4;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Required designer variable.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private System.ComponentModel.Container components = null;
InBlock.gif
InBlock.gif        
private System.Windows.Forms.Panel panel1;
InBlock.gif
InBlock.gif        
private const int DEFAULT_WIDTH_SIZE = 136;
InBlock.gif        
private const int DEFAULT_HEIGHT_SIZE = 20;
InBlock.gif        
private string _text = "";
InBlock.gif        
private bool _isAllowWarn = true;
InBlock.gif        
private Languages _language = Languages.English;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Usable languages enumeration.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public enum Languages
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// English language
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            English,
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// Chinese language
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            Chinese
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Creates an instance of the IPBox class.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public IPBox()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// This call is required by the Windows.Forms Form Designer.
InBlock.gif
            InitializeComponent();
InBlock.gif
InBlock.gif            
// TODO: Add any initialization after the InitComponent call
InBlock.gif

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Clean up any resources being used.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        protected override void Dispose(bool disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (components != null)
InBlock.gif                    components.Dispose();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
base.Dispose(disposing);
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Component Designer generated code#region Component Designer generated code
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Required method for Designer support - do not modify 
InBlock.gif        
/// the contents of this method with the code editor.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.textBox1 = new System.Windows.Forms.TextBox();
InBlock.gif            
this.label1 = new System.Windows.Forms.Label();
InBlock.gif            
this.label2 = new System.Windows.Forms.Label();
InBlock.gif            
this.textBox2 = new System.Windows.Forms.TextBox();
InBlock.gif            
this.label3 = new System.Windows.Forms.Label();
InBlock.gif            
this.textBox3 = new System.Windows.Forms.TextBox();
InBlock.gif            
this.textBox4 = new System.Windows.Forms.TextBox();
InBlock.gif            
this.panel1 = new System.Windows.Forms.Panel();
InBlock.gif            
this.panel1.SuspendLayout();
InBlock.gif            
this.SuspendLayout();
InBlock.gif            
// 
InBlock.gif            
// textBox1
InBlock.gif            
// 
InBlock.gif
            this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
InBlock.gif            
this.textBox1.Location = new System.Drawing.Point(80);
InBlock.gif            
this.textBox1.MaxLength = 3;
InBlock.gif            
this.textBox1.Name = "textBox1";
InBlock.gif            
this.textBox1.Size = new System.Drawing.Size(2013);
InBlock.gif            
this.textBox1.TabIndex = 0;
InBlock.gif            
this.textBox1.Text = "";
InBlock.gif            
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
InBlock.gif            
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
InBlock.gif            
// 
InBlock.gif            
// label1
InBlock.gif            
// 
InBlock.gif
            this.label1.BackColor = System.Drawing.SystemColors.Window;
InBlock.gif            
this.label1.Location = new System.Drawing.Point(320);
InBlock.gif            
this.label1.Name = "label1";
InBlock.gif            
this.label1.Size = new System.Drawing.Size(814);
InBlock.gif            
this.label1.TabIndex = 1;
InBlock.gif            
this.label1.Text = ".";
InBlock.gif            
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
InBlock.gif            
// 
InBlock.gif            
// label2
InBlock.gif            
// 
InBlock.gif
            this.label2.BackColor = System.Drawing.SystemColors.Window;
InBlock.gif            
this.label2.Location = new System.Drawing.Point(640);
InBlock.gif            
this.label2.Name = "label2";
InBlock.gif            
this.label2.Size = new System.Drawing.Size(814);
InBlock.gif            
this.label2.TabIndex = 3;
InBlock.gif            
this.label2.Text = ".";
InBlock.gif            
this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
InBlock.gif            
// 
InBlock.gif            
// textBox2
InBlock.gif            
// 
InBlock.gif
            this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
InBlock.gif            
this.textBox2.Location = new System.Drawing.Point(400);
InBlock.gif            
this.textBox2.MaxLength = 3;
InBlock.gif            
this.textBox2.Name = "textBox2";
InBlock.gif            
this.textBox2.Size = new System.Drawing.Size(2013);
InBlock.gif            
this.textBox2.TabIndex = 2;
InBlock.gif            
this.textBox2.Text = "";
InBlock.gif            
this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
InBlock.gif            
this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
InBlock.gif            
// 
InBlock.gif            
// label3
InBlock.gif            
// 
InBlock.gif
            this.label3.BackColor = System.Drawing.SystemColors.Window;
InBlock.gif            
this.label3.Location = new System.Drawing.Point(960);
InBlock.gif            
this.label3.Name = "label3";
InBlock.gif            
this.label3.Size = new System.Drawing.Size(814);
InBlock.gif            
this.label3.TabIndex = 5;
InBlock.gif            
this.label3.Text = ".";
InBlock.gif            
this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
InBlock.gif            
// 
InBlock.gif            
// textBox3
InBlock.gif            
// 
InBlock.gif
            this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.None;
InBlock.gif            
this.textBox3.Location = new System.Drawing.Point(720);
InBlock.gif            
this.textBox3.MaxLength = 3;
InBlock.gif            
this.textBox3.Name = "textBox3";
InBlock.gif            
this.textBox3.Size = new System.Drawing.Size(2013);
InBlock.gif            
this.textBox3.TabIndex = 4;
InBlock.gif            
this.textBox3.Text = "";
InBlock.gif            
this.textBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
InBlock.gif            
this.textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox3_KeyPress);
InBlock.gif            
// 
InBlock.gif            
// textBox4
InBlock.gif            
// 
InBlock.gif
            this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.None;
InBlock.gif            
this.textBox4.Location = new System.Drawing.Point(1040);
InBlock.gif            
this.textBox4.MaxLength = 3;
InBlock.gif            
this.textBox4.Name = "textBox4";
InBlock.gif            
this.textBox4.Size = new System.Drawing.Size(2013);
InBlock.gif            
this.textBox4.TabIndex = 6;
InBlock.gif            
this.textBox4.Text = "";
InBlock.gif            
this.textBox4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
InBlock.gif            
this.textBox4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox4_KeyPress);
InBlock.gif            
// 
InBlock.gif            
// panel1
InBlock.gif            
// 
InBlock.gif
            this.panel1.BackColor = System.Drawing.SystemColors.Window;
InBlock.gif            
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
InBlock.gif            
this.panel1.Controls.Add(this.textBox1);
InBlock.gif            
this.panel1.Controls.Add(this.textBox4);
InBlock.gif            
this.panel1.Controls.Add(this.label1);
InBlock.gif            
this.panel1.Controls.Add(this.label3);
InBlock.gif            
this.panel1.Controls.Add(this.textBox3);
InBlock.gif            
this.panel1.Controls.Add(this.textBox2);
InBlock.gif            
this.panel1.Controls.Add(this.label2);
InBlock.gif            
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
InBlock.gif            
this.panel1.Location = new System.Drawing.Point(00);
InBlock.gif            
this.panel1.Name = "panel1";
InBlock.gif            
this.panel1.Size = new System.Drawing.Size(13620);
InBlock.gif            
this.panel1.TabIndex = 8;
InBlock.gif            
// 
InBlock.gif            
// IPBox
InBlock.gif            
// 
InBlock.gif
            this.Controls.Add(this.panel1);
InBlock.gif            
this.Name = "IPBox";
InBlock.gif            
this.Size = new System.Drawing.Size(13620);
InBlock.gif            
this.SizeChanged += new System.EventHandler(this.IPBox_SizeChanged);
InBlock.gif            
this.panel1.ResumeLayout(false);
InBlock.gif            
this.ResumeLayout(false);
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Masks IP Address.
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="textBox"></param>
ExpandedSubBlockEnd.gif        
/// <param name="e"></param>

InBlock.gif        private void MaskIPAddress(TextBox textBox, KeyPressEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// Only allow digit, '.' and "BackSpace" key.
InBlock.gif
            if (Char.IsDigit(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == 8)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (e.KeyChar != 8)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if (textBox.Text.Length == 2 && e.KeyChar != '.')
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        Validate(textBox, textBox.Text 
+ e.KeyChar);
InBlock.gif                        e.Handled 
= true;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else if (e.KeyChar == '.')
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
if (textBox.Text.Length == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            textBox.Text 
= "";
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            FocusNext(textBox);
ExpandedSubBlockEnd.gif                        }

InBlock.gif                        e.Handled 
= true;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if (textBox.Text.Length == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    FocusPreviouse(textBox);
InBlock.gif                    e.Handled 
= false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                e.Handled 
= true// Ignore other keys
ExpandedSubBlockEnd.gif
            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Focuses the previous textbox.
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="textBox"></param>

InBlock.gif        private void FocusPreviouse(TextBox textBox)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
switch (textBox.Name)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
case "textBox2":
InBlock.gif                    textBox1.Focus();
InBlock.gif                    textBox1.SelectionStart 
= textBox1.Text.Length;
InBlock.gif                    
break;
InBlock.gif                
case "textBox3":
InBlock.gif                    textBox2.Focus();
InBlock.gif                    textBox2.SelectionStart 
= textBox2.Text.Length;
InBlock.gif                    
break;
InBlock.gif                
case "textBox4":
InBlock.gif                    textBox3.Focus();
InBlock.gif                    textBox3.SelectionStart 
= textBox3.Text.Length;
InBlock.gif                    
break;
InBlock.gif                
default:
InBlock.gif                    
break;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Focuses the next textbox.
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="textBox"></param>

InBlock.gif        private void FocusNext(TextBox textBox)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
switch (textBox.Name)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
case "textBox1":
InBlock.gif                    textBox2.Focus();
InBlock.gif                    textBox2.SelectAll();
InBlock.gif                    
break;
InBlock.gif                
case "textBox2":
InBlock.gif                    textBox3.Focus();
InBlock.gif                    textBox3.SelectAll();
InBlock.gif                    
break;
InBlock.gif                
case "textBox3":
InBlock.gif                    textBox4.Focus();
InBlock.gif                    textBox4.SelectAll();
InBlock.gif                    
break;
InBlock.gif                
default:
InBlock.gif                    
break;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Validates whether the string is correct.
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="currentTextBox">Current textbox</param>
ExpandedSubBlockEnd.gif        
/// <param name="str">input string</param>

InBlock.gif        private void Validate(TextBox currentTextBox, string str)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int maxValue = currentTextBox.Name.Equals("textBox1"? 233 : 255;
InBlock.gif
InBlock.gif            TextBox nextTextBox 
= currentTextBox;
InBlock.gif            
switch (currentTextBox.Name)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
case "textBox1":
InBlock.gif                    nextTextBox 
= textBox2;
InBlock.gif                    
break;
InBlock.gif                
case "textBox2":
InBlock.gif                    nextTextBox 
= textBox3;
InBlock.gif                    
break;
InBlock.gif                
case "textBox3":
InBlock.gif                    nextTextBox 
= textBox4;
InBlock.gif                    
break;
InBlock.gif                
default:
InBlock.gif                    
break;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
if (Int32.Parse(str) > maxValue)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                currentTextBox.Text 
= maxValue.ToString();
InBlock.gif                currentTextBox.Focus();
InBlock.gif                
if (AllowWarn)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
switch (Language)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
case Languages.English:
InBlock.gif                            MessageBox.Show(str 
+ " is not a valid entry. Please specify a value between 1 and " +
InBlock.gif                                maxValue, 
"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
InBlock.gif                            
break;
InBlock.gif                        
case Languages.Chinese:
InBlock.gif                            MessageBox.Show(str 
+ " 不是一个有效值。请指定一个介于 1 和 " + maxValue +
InBlock.gif                                
" 之间的数值""错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
InBlock.gif                            
break;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                currentTextBox.Text 
= str;
InBlock.gif                
if (!nextTextBox.Equals(currentTextBox))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    nextTextBox.Focus();
InBlock.gif                    nextTextBox.SelectAll();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    currentTextBox.SelectionStart 
= currentTextBox.Text.Length;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Overrided. Returns IP Address.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public override string Text
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 ||
InBlock.gif                    textBox3.Text.Length 
== 0 || textBox4.Text.Length == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    _text 
= "";
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    _text 
= textBox1.Text + "." + textBox2.Text +
InBlock.gif                        
"." + textBox3.Text + "." + textBox4.Text;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return _text;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Returns whether allow warining informaiton when user input incorrect format.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public bool AllowWarn
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn _isAllowWarn; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ _isAllowWarn = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Specifies language of warning information.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public Languages Language
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
get dot.gifreturn _language; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
set dot.gif{ _language = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Overrided. Returns whether the IPBox control is focused.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public override bool Focused
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (textBox1.Focused || textBox2.Focused ||
InBlock.gif                    textBox3.Focused 
|| textBox4.Focused)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Focus the IPBox.
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public new bool Focus()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return textBox1.Focus();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Clears the IPBox's Text.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public void Clear()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            textBox1.Clear();
InBlock.gif            textBox2.Clear();
InBlock.gif            textBox3.Clear();
InBlock.gif            textBox4.Clear();
InBlock.gif            textBox1.Focus();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Forbids to change the size of IPBox Control.
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="sender"></param>
ExpandedSubBlockEnd.gif        
/// <param name="e"></param>

InBlock.gif        private void IPBox_SizeChanged(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.Width = DEFAULT_WIDTH_SIZE;
InBlock.gif            
this.Height = DEFAULT_HEIGHT_SIZE;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            MaskIPAddress(textBox1, e);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            MaskIPAddress(textBox2, e);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void textBox3_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            MaskIPAddress(textBox3, e);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void textBox4_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            MaskIPAddress(textBox4, e);
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/seagle0128/archive/2004/10/31/58823.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值