Click here to Skip to main content
15,895,667 members
Articles / Programming Languages / C#

A C# IP Address Control

Rate me:
Please Sign up or sign in to vote.
4.72/5 (98 votes)
28 Apr 2008MIT4 min read 788.4K   39.8K   297  
A C# analogue to the MFC CIPAddressCtrl
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestIPAddressControl
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
      private System.Windows.Forms.Label label1;
      private IPAddressControlLib.IPAddressControl ipAddressControl1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
         this.label1 = new System.Windows.Forms.Label();
         this.ipAddressControl1 = new IPAddressControlLib.IPAddressControl();
         this.SuspendLayout();
         // 
         // label1
         // 
         this.label1.Location = new System.Drawing.Point(16, 16);
         this.label1.Name = "label1";
         this.label1.Size = new System.Drawing.Size(64, 13);
         this.label1.TabIndex = 0;
         this.label1.Text = "IP Address:";
         this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
         // 
         // ipAddressControl1
         // 
         this.ipAddressControl1.AutoHeight = true;
         this.ipAddressControl1.BackColor = System.Drawing.SystemColors.Window;
         this.ipAddressControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.ipAddressControl1.Location = new System.Drawing.Point(88, 12);
         this.ipAddressControl1.Name = "ipAddressControl1";
         this.ipAddressControl1.ReadOnly = false;
         this.ipAddressControl1.Size = new System.Drawing.Size(108, 20);
         this.ipAddressControl1.TabIndex = 1;
         this.ipAddressControl1.Text = "192.168.10.10";
         // 
         // Form1
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
         this.ClientSize = new System.Drawing.Size(292, 54);
         this.Controls.Add(this.ipAddressControl1);
         this.Controls.Add(this.label1);
         this.Name = "Form1";
         this.Text = "Form1";
         this.ResumeLayout(false);

      }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions