home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2002 September / PCPlus_193_Laplink2000.iso / Prog / c# / myControl / UserControl1.cs < prev    next >
Encoding:
Text File  |  2002-05-02  |  2.5 KB  |  105 lines

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Windows.Forms;
  7.  
  8. namespace myControl
  9. {
  10.     /// <summary>
  11.     /// Summary description for UserControl1.
  12.     /// </summary>
  13.     public class myCtrl : System.Windows.Forms.UserControl
  14.     {
  15.         private string _msg = "Hello world!";
  16.  
  17.         private System.Windows.Forms.TextBox textBox1;
  18.         private System.Windows.Forms.Button button1;
  19.         /// <summary>
  20.         /// Required designer variable.
  21.         /// </summary>
  22.         private System.ComponentModel.Container components = null;
  23.  
  24.         public myCtrl()
  25.         {
  26.             // This call is required by the Windows.Forms Form Designer.
  27.             InitializeComponent();
  28.  
  29.             // TODO: Add any initialization after the InitForm call
  30.  
  31.         }
  32.  
  33.         /// <summary>
  34.         /// Clean up any resources being used.
  35.         /// </summary>
  36.         protected override void Dispose( bool disposing )
  37.         {
  38.             if( disposing )
  39.             {
  40.                 if( components != null )
  41.                     components.Dispose();
  42.             }
  43.             base.Dispose( disposing );
  44.         }
  45.  
  46.         #region Component Designer generated code
  47.         /// <summary>
  48.         /// Required method for Designer support - do not modify 
  49.         /// the contents of this method with the code editor.
  50.         /// </summary>
  51.         private void InitializeComponent()
  52.         {
  53.             this.textBox1 = new System.Windows.Forms.TextBox();
  54.             this.button1 = new System.Windows.Forms.Button();
  55.             this.SuspendLayout();
  56.             // 
  57.             // textBox1
  58.             // 
  59.             this.textBox1.Location = new System.Drawing.Point(24, 24);
  60.             this.textBox1.Name = "textBox1";
  61.             this.textBox1.TabIndex = 0;
  62.             this.textBox1.Text = "";
  63.             // 
  64.             // button1
  65.             // 
  66.             this.button1.Location = new System.Drawing.Point(24, 80);
  67.             this.button1.Name = "button1";
  68.             this.button1.TabIndex = 1;
  69.             this.button1.Text = "Click Me!";
  70.             this.button1.Click += new System.EventHandler(this.button1_Click);
  71.             // 
  72.             // myControl
  73.             // 
  74.             this.Controls.AddRange(new System.Windows.Forms.Control[] {
  75.                                                                           this.button1,
  76.                                                                           this.textBox1});
  77.             this.Name = "myControl";
  78.             this.ResumeLayout(false);
  79.  
  80.         }
  81.         #endregion
  82.  
  83.         // User-defined Properties
  84.         [Browsable(true),
  85.         Category("Absolutely Fabulous"),
  86.         Description("Specifies the message to display when the Button is clicked.")
  87.             ]
  88.         public string Msg
  89.         {
  90.             get
  91.             {
  92.                 return _msg;
  93.             }
  94.             set
  95.             {
  96.                 _msg = value;
  97.             }
  98.         }
  99.         private void button1_Click(object sender, System.EventArgs e)
  100.         {
  101.             textBox1.Text = Msg;
  102.         }
  103.     }
  104. }
  105.