TextBox Demo


   

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TextBox
{
    /// <summary>
    /// Summary description for TextBox.
    /// </summary>
    public class TextBox : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox SINGLE_LINE;
        private System.Windows.Forms.TextBox PASSWORD_LINE;
        private System.Windows.Forms.TextBox MULTI_LINE;
        private System.Windows.Forms.RichTextBox RICH_EDIT;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public TextBox()
        {
            //
            // 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.SINGLE_LINE = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.PASSWORD_LINE = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.MULTI_LINE = new System.Windows.Forms.TextBox();
            this.RICH_EDIT = new System.Windows.Forms.RichTextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // SINGLE_LINE
            // 
            this.SINGLE_LINE.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.SINGLE_LINE.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(64)), ((System.Byte)(64)));
            this.SINGLE_LINE.Location = new System.Drawing.Point(32, 40);
            this.SINGLE_LINE.Name = "SINGLE_LINE";
            this.SINGLE_LINE.Size = new System.Drawing.Size(408, 20);
            this.SINGLE_LINE.TabIndex = 0;
            this.SINGLE_LINE.Text = "THIS IS A SINGLELINE EDIT CONTROL";
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(32, 24);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(168, 16);
            this.label1.TabIndex = 1;
            this.label1.Text = "Single Line TextBox";
            // 
            // PASSWORD_LINE
            // 
            this.PASSWORD_LINE.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.PASSWORD_LINE.Location = new System.Drawing.Point(32, 104);
            this.PASSWORD_LINE.Name = "PASSWORD_LINE";
            this.PASSWORD_LINE.PasswordChar = &#039;^&#039;;
            this.PASSWORD_LINE.Size = new System.Drawing.Size(104, 22);
            this.PASSWORD_LINE.TabIndex = 2;
            this.PASSWORD_LINE.Text = "";
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(32, 80);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(160, 16);
            this.label2.TabIndex = 3;
            this.label2.Text = "Password TextBox";
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(32, 136);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(120, 16);
            this.label3.TabIndex = 4;
            this.label3.Text = "MultiLine TextBox";
            // 
            // MULTI_LINE
            // 
            this.MULTI_LINE.AcceptsReturn = true;
            this.MULTI_LINE.AcceptsTab = true;
            this.MULTI_LINE.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.MULTI_LINE.ForeColor = System.Drawing.SystemColors.HotTrack;
            this.MULTI_LINE.Location = new System.Drawing.Point(32, 160);
            this.MULTI_LINE.MaxLength = 10000;
            this.MULTI_LINE.Multiline = true;
            this.MULTI_LINE.Name = "MULTI_LINE";
            this.MULTI_LINE.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.MULTI_LINE.Size = new System.Drawing.Size(408, 104);
            this.MULTI_LINE.TabIndex = 5;
            this.MULTI_LINE.Text = "";
            // 
            // RICH_EDIT
            // 
            this.RICH_EDIT.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.RICH_EDIT.ForeColor = System.Drawing.Color.Red;
            this.RICH_EDIT.Location = new System.Drawing.Point(32, 296);
            this.RICH_EDIT.Name = "RICH_EDIT";
            this.RICH_EDIT.ShowSelectionMargin = true;
            this.RICH_EDIT.Size = new System.Drawing.Size(408, 120);
            this.RICH_EDIT.TabIndex = 6;
            this.RICH_EDIT.Text = "richTextBox1";
            this.RICH_EDIT.ZoomFactor = 4.999695F;
            // 
            // label4
            // 
            this.label4.Location = new System.Drawing.Point(32, 272);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(152, 16);
            this.label4.TabIndex = 7;
            this.label4.Text = "RichEdit Text Box";
            // 
            // TextBox
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(464, 453);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.label4,
                                                                          this.RICH_EDIT,
                                                                          this.MULTI_LINE,
                                                                          this.label3,
                                                                          this.label2,
                                                                          this.PASSWORD_LINE,
                                                                          this.label1,
                                                                          this.SINGLE_LINE});
            this.Name = "TextBox";
            this.Text = "TextBox Controls";
            this.Load += new System.EventHandler(this.TextBox_Load);
            this.ResumeLayout(false);

        }
        #endregion

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

        private void TextBox_Load(object sender, System.EventArgs e)
        {
            RICH_EDIT.LoadFile("c:	empRTFDOC.RTF");     
        }
    }
}


           
          


Label, TextBox and Button


   

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ControlMedley
{
    /// <summary>
    /// Summary description for ControlMedley.
    /// </summary>
    public class ControlMedley : System.Windows.Forms.Form
    {
        internal System.Windows.Forms.Label Label1;
        internal System.Windows.Forms.TextBox TextBox1;
        internal System.Windows.Forms.Button Button1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public ControlMedley()
        {
            //
            // 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.TextBox1 = new System.Windows.Forms.TextBox();
            this.Button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // Label1
            // 
            this.Label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.Label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Label1.Location = new System.Drawing.Point(20, 92);
            this.Label1.Name = "Label1";
            this.Label1.Size = new System.Drawing.Size(112, 24);
            this.Label1.TabIndex = 5;
            this.Label1.Text = "Label1";
            this.Label1.Click += new System.EventHandler(this.ctrlClick);
            // 
            // TextBox1
            // 
            this.TextBox1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.TextBox1.Location = new System.Drawing.Point(20, 56);
            this.TextBox1.Name = "TextBox1";
            this.TextBox1.Size = new System.Drawing.Size(156, 21);
            this.TextBox1.TabIndex = 4;
            this.TextBox1.Text = "TextBox1";
            this.TextBox1.Click += new System.EventHandler(this.ctrlClick);
            // 
            // Button1
            // 
            this.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.Button1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Button1.Location = new System.Drawing.Point(20, 16);
            this.Button1.Name = "Button1";
            this.Button1.Size = new System.Drawing.Size(96, 28);
            this.Button1.TabIndex = 3;
            this.Button1.Text = "Button1";
            this.Button1.Click += new System.EventHandler(this.ctrlClick);
            // 
            // ControlMedley
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.ClientSize = new System.Drawing.Size(316, 214);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.Label1,
                                                                          this.TextBox1,
                                                                          this.Button1});
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Name = "ControlMedley";
            this.Text = "Control Medley";
            this.ResumeLayout(false);

        }
        #endregion

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

        private void ctrlClick(System.Object sender, EventArgs e)
        {
            Control ctrl = (Control)sender;
            MessageBox.Show("You clicked: " + ctrl.Name);
        }

    }
}


           
          


TextBox and ListBox


   


using System;
using System.Drawing;
using System.Windows.Forms;


public class WindowSample : Form
{
   private TextBox data;
   private ListBox results;

   public WindowSample()
   {
      Text = "Sample Window Program";
      Size = new Size(400, 380);

      Label label1 = new Label();
      label1.Parent = this;
      label1.Text = "Enter text string:";
      label1.AutoSize = true;
      label1.Location = new Point(10, 10);

      data = new TextBox();
      data.Parent = this;
      data.Size = new Size(200, 2 * Font.Height);
      data.Location = new Point(10, 35);

      results = new ListBox();
      results.Parent = this;
      results.Location = new Point(10, 65);
      results.Size = new Size(350, 20 * Font.Height);

      Button checkit = new Button();
      checkit.Parent = this;
      checkit.Text = "test";
      checkit.Location = new Point(235,32);
      checkit.Size = new Size(7 * Font.Height, 2 * Font.Height);
      checkit.Click += new EventHandler(ButtonOnClick);
   }

   void ButtonOnClick(object obj, EventArgs ea)
   {
      results.Items.Add(data.Text);
      data.Clear();
   }

   public static void Main()
   {
      Application.Run(new WindowSample());
   }
}
           
          


TextBox and button on form


   

/*
C# Programming Tips &amp; Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Form
{
  /// <summary>
  /// Summary description for ButtonTextForm.
  /// </summary>
  public class ButtonTextForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.TextBox textBox1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

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

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


    #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.button1 = new System.Windows.Forms.Button();
      this.button2 = new System.Windows.Forms.Button();
      this.textBox1 = new System.Windows.Forms.TextBox();
      this.SuspendLayout();
      // 
      // button1
      // 
      this.button1.Location = new System.Drawing.Point(61, 159);
      this.button1.Name = "button1";
      this.button1.Size = new System.Drawing.Size(85, 37);
      this.button1.TabIndex = 1;
      this.button1.Text = "button1";
      // 
      // button2
      // 
      this.button2.Location = new System.Drawing.Point(196, 159);
      this.button2.Name = "button2";
      this.button2.Size = new System.Drawing.Size(95, 37);
      this.button2.TabIndex = 2;
      this.button2.Text = "button2";
      // 
      // textBox1
      // 
      this.textBox1.Location = new System.Drawing.Point(41, 37);
      this.textBox1.Name = "textBox1";
      this.textBox1.Size = new System.Drawing.Size(262, 22);
      this.textBox1.TabIndex = 0;
      this.textBox1.Text = "textBox1";
      // 
      // ButtonTextForm
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
      this.ClientSize = new System.Drawing.Size(340, 280);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.button1,
                                      this.button2,
                                      this.textBox1});
      this.Name = "ButtonTextForm";
      this.Text = "ButtonTextForm";
      this.Load += new System.EventHandler(this.ButtonTextForm_Load);
      this.ResumeLayout(false);

    }
    #endregion

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

    private void ButtonTextForm_Load(object sender, System.EventArgs e)
    {

    }

    private void button2_Click(object sender, System.EventArgs e)
    {
      Application.Exit ();
    }

    private void button1_Click(object sender, System.EventArgs e)
    {
      MessageBox.Show (this,
        textBox1.Text, "Text Box",
        MessageBoxButtons.OKCancel,
        MessageBoxIcon.Exclamation);
    }
  }
}


           
          


User Events


   

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace UserEvents
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class UserEvents : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox txtUsername;
        private System.Windows.Forms.Button btnLogin;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        LoginAuditInserter la = new LoginAuditInserter();
        public UserEvents()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

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

            
            la.LoginAudit += new LoginAuditInserter.LoginAuditHandler(AddAuditEntry);
            la.LoginAudit += new LoginAuditInserter.LoginAuditHandler(AddEventLogEntry);
        }

        static public void AddAuditEntry(string username)
        {
            System.Diagnostics.Debug.WriteLine(username);
        }

        static public void AddEventLogEntry(string username)
        {
            string applicationName = "Login Audit";
            EventLog ev = new EventLog("Application");
            ev.Source = applicationName;
            ev.WriteEntry("Login Attempted.", EventLogEntryType.Information);
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null) 
                {
                    components.Dispose();
                }
            }
            la.LoginAudit -= new LoginAuditInserter.LoginAuditHandler(AddAuditEntry);
            la.LoginAudit -= new LoginAuditInserter.LoginAuditHandler(AddEventLogEntry);

            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.txtUsername = new System.Windows.Forms.TextBox();
            this.btnLogin = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // txtUsername
            // 
            this.txtUsername.Location = new System.Drawing.Point(8, 24);
            this.txtUsername.Name = "txtUsername";
            this.txtUsername.Size = new System.Drawing.Size(152, 20);
            this.txtUsername.TabIndex = 0;
            this.txtUsername.Text = "";
            // 
            // btnLogin
            // 
            this.btnLogin.Location = new System.Drawing.Point(184, 24);
            this.btnLogin.Name = "btnLogin";
            this.btnLogin.Size = new System.Drawing.Size(96, 23);
            this.btnLogin.TabIndex = 1;
            this.btnLogin.Text = "Login";
            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
            // 
            // UserEvents
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(292, 78);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.btnLogin,
                                                                          this.txtUsername});
            this.MaximizeBox = false;
            this.Name = "UserEvents";
            this.Text = "Login";
            this.ResumeLayout(false);

        }
        #endregion

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

        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            la.AddAuditEntry(txtUsername.Text);     
        }
    }

    public class LoginAuditInserter
    {
        public delegate void LoginAuditHandler(string username);

        private AccessorContainer container = new AccessorContainer();
        private static int key = 0;

        public event LoginAuditHandler LoginAudit
        {
            [MethodImpl(MethodImplOptions.Synchronized)]
            add
            {
                container.Add(key, value);
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            remove
            {
                container.Remove(key, value);
            }
        }

        protected void OnLoginAudit(string username)
        {
            LoginAuditHandler loginAudit = (LoginAuditHandler)container.Get(key);
            if(username!=null)
            {
                loginAudit(username);
            }
        }

        public void AddAuditEntry(string username)
        {
            OnLoginAudit(username);
        }
    }

    public class AccessorContainer
    {
        private ArrayList arrayAccessor = new ArrayList();

        public Delegate Get(int key)
        {
            return ((Delegate)arrayAccessor[key]);
        }

        public void Add(int key, Delegate ptr)
        {
            try
            {
                arrayAccessor[key] = Delegate.Combine((Delegate)arrayAccessor[key], ptr);
            }
            catch(ArgumentOutOfRangeException)
            {
                arrayAccessor.Add(ptr);
            }
        }

        public void Remove(int key, Delegate ptr)
        {
            arrayAccessor.Remove(Delegate.Remove((Delegate)arrayAccessor[key], ptr));
        }
    }


}

           
          


Data Checker


   

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Threading;


namespace DataChecker
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class DataChecker : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox txtCoffeePrice;
        private System.Windows.Forms.TextBox txtTeaPrice;
        private System.Windows.Forms.TextBox txtGoldPrice;
        private System.Windows.Forms.Label lblCoffeePrice;
        private System.Windows.Forms.Label lblTeaPrice;
        private System.Windows.Forms.Label lblGoldPrice;

        private int lastCoffeePrice = 0;
        private int lastTeaPrice = 0;
        private int lastGoldPrice = 0;
        private int allUpdates = 0;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;
        private System.Threading.Timer t1 = null;
        private System.Threading.Timer t2 = null;
        private System.Threading.Timer t3 = null;

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

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

            t1 = new System.Threading.Timer(new TimerCallback(Timer_Callback), &#039;C&#039;, 0, 500);
            t2 = new System.Threading.Timer(new TimerCallback(Timer_Callback), &#039;T&#039;, 1, 500);
            t3 = new System.Threading.Timer(new TimerCallback(Timer_Callback), &#039;G&#039;, 2, 500);        

            /*WaitOrTimerCallback wotc = new WaitOrTimerCallback(GetData);
            AutoResetEvent are = new AutoResetEvent(false);
            ThreadPool.RegisterWaitForSingleObject(are, new WaitOrTimerCallback(GetData), &#039;C&#039;, 500, false);*/

        }

        protected void Timer_Callback(object state)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(GetData), state);
        }


        int retVal;
        private void GetData(object type)
        {
            char priceType = (char)type;
            string sql = null;

            sql = "SELECT Price FROM tblPrices WHERE Type=&#039;"+priceType.ToString()+"&#039;";

            SqlConnection cn = new SqlConnection("Server=localhost; Database=Prices; Integrated Security=SSPI");
            cn.Open();

            SqlCommand cmd = new SqlCommand(sql, cn);

            
            lock(this)
            {
                retVal = (int)cmd.ExecuteScalar(); 
                switch(priceType) 
                {
                    case &#039;C&#039;:
                        lastCoffeePrice = Convert.ToInt32(txtCoffeePrice.Text);
                        txtCoffeePrice.Text = retVal.ToString();
                        break;
                    case &#039;T&#039;:
                        lastTeaPrice = Convert.ToInt32(txtTeaPrice.Text);
                        txtTeaPrice.Text = retVal.ToString();
                        break;
                    case &#039;G&#039;:
                        lastGoldPrice = Convert.ToInt32(txtGoldPrice.Text);
                        txtGoldPrice.Text = retVal.ToString();
                        break;
                }
            }
            

            allUpdates++;
            cn.Close();
        }

        /// <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.txtCoffeePrice = new System.Windows.Forms.TextBox();
            this.txtTeaPrice = new System.Windows.Forms.TextBox();
            this.txtGoldPrice = new System.Windows.Forms.TextBox();
            this.lblCoffeePrice = new System.Windows.Forms.Label();
            this.lblTeaPrice = new System.Windows.Forms.Label();
            this.lblGoldPrice = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // txtCoffeePrice
            // 
            this.txtCoffeePrice.Location = new System.Drawing.Point(72, 24);
            this.txtCoffeePrice.Name = "txtCoffeePrice";
            this.txtCoffeePrice.TabIndex = 0;
            this.txtCoffeePrice.Text = "0";
            // 
            // txtTeaPrice
            // 
            this.txtTeaPrice.Location = new System.Drawing.Point(192, 24);
            this.txtTeaPrice.Name = "txtTeaPrice";
            this.txtTeaPrice.TabIndex = 1;
            this.txtTeaPrice.Text = "0";
            // 
            // txtGoldPrice
            // 
            this.txtGoldPrice.Location = new System.Drawing.Point(312, 24);
            this.txtGoldPrice.Name = "txtGoldPrice";
            this.txtGoldPrice.TabIndex = 2;
            this.txtGoldPrice.Text = "0";
            // 
            // lblCoffeePrice
            // 
            this.lblCoffeePrice.Location = new System.Drawing.Point(72, 0);
            this.lblCoffeePrice.Name = "lblCoffeePrice";
            this.lblCoffeePrice.TabIndex = 3;
            this.lblCoffeePrice.Text = "Coffee Price";
            // 
            // lblTeaPrice
            // 
            this.lblTeaPrice.Location = new System.Drawing.Point(192, 0);
            this.lblTeaPrice.Name = "lblTeaPrice";
            this.lblTeaPrice.TabIndex = 4;
            this.lblTeaPrice.Text = "Tea Price";
            // 
            // lblGoldPrice
            // 
            this.lblGoldPrice.Location = new System.Drawing.Point(320, 0);
            this.lblGoldPrice.Name = "lblGoldPrice";
            this.lblGoldPrice.TabIndex = 5;
            this.lblGoldPrice.Text = "Gold Price";
            // 
            // DataChecker
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(424, 54);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.lblGoldPrice,
                                                                          this.lblTeaPrice,
                                                                          this.lblCoffeePrice,
                                                                          this.txtGoldPrice,
                                                                          this.txtTeaPrice,
                                                                          this.txtCoffeePrice});
            this.MaximizeBox = false;
            this.Name = "DataChecker";
            this.Text = "Data Checker";
            this.ResumeLayout(false);

        }
        #endregion

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

        
    }
}


           
          


All cap text textbox


   



    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

  public class TextForm : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button btnPasswordDecoderRing;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox passwordBox;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox capsOnlyBox;
    private System.Windows.Forms.Button btnGetMultiLineText;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox multiLineBox;

        public TextForm()
        {
            InitializeComponent();
        }

    private void InitializeComponent()
    {
      this.capsOnlyBox = new System.Windows.Forms.TextBox();
      this.multiLineBox = new System.Windows.Forms.TextBox();
      this.label1 = new System.Windows.Forms.Label();
      this.label2 = new System.Windows.Forms.Label();
      this.passwordBox = new System.Windows.Forms.TextBox();
      this.btnGetMultiLineText = new System.Windows.Forms.Button();
      this.btnPasswordDecoderRing = new System.Windows.Forms.Button();
      this.label3 = new System.Windows.Forms.Label();
      this.capsOnlyBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
      this.capsOnlyBox.Location = new System.Drawing.Point(14, 176);
      this.capsOnlyBox.Size = new System.Drawing.Size(120, 20);
      this.capsOnlyBox.TabIndex = 3;
      this.multiLineBox.AcceptsReturn = true;
      this.multiLineBox.AcceptsTab = true;
      this.multiLineBox.Location = new System.Drawing.Point(152, 8);
      this.multiLineBox.Multiline = true;
      this.multiLineBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
      this.multiLineBox.Size = new System.Drawing.Size(240, 104);
      this.multiLineBox.TabIndex = 0;
      this.multiLineBox.Text = "Get text from multiline textbox";
      this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F);
      this.label1.Location = new System.Drawing.Point(8, 8);
      this.label1.Size = new System.Drawing.Size(136, 56);
      this.label1.TabIndex = 1;
      this.label1.Text = "this is a multiline text box";
      this.label2.Font = new System.Drawing.Font("Comic Sans MS", 12F);
      this.label2.Location = new System.Drawing.Point(14, 144);
      this.label2.Size = new System.Drawing.Size(106, 24);
      this.label2.TabIndex = 4;
      this.label2.Text = "Caps only!!";
      this.passwordBox.Location = new System.Drawing.Point(160, 176);
      this.passwordBox.PasswordChar = &#039;$&#039;;
      this.passwordBox.Size = new System.Drawing.Size(232, 20);
      this.passwordBox.TabIndex = 5;
      this.passwordBox.Text = "password";
      this.btnGetMultiLineText.Location = new System.Drawing.Point(13, 72);
      this.btnGetMultiLineText.Size = new System.Drawing.Size(120, 32);
      this.btnGetMultiLineText.TabIndex = 2;
      this.btnGetMultiLineText.Text = "Get Text";
      this.btnGetMultiLineText.Click += new System.EventHandler(this.btnGetMultiLineText_Click);
      this.btnPasswordDecoderRing.Location = new System.Drawing.Point(280, 144);
      this.btnPasswordDecoderRing.Size = new System.Drawing.Size(112, 24);
      this.btnPasswordDecoderRing.TabIndex = 7;
      this.btnPasswordDecoderRing.Text = "Decode Password";
      this.btnPasswordDecoderRing.Click += new System.EventHandler(this.btnPasswordDecoderRing_Click);
      this.label3.Font = new System.Drawing.Font("Comic Sans MS", 12F);
      this.label3.Location = new System.Drawing.Point(152, 144);
      this.label3.Size = new System.Drawing.Size(120, 24);
      this.label3.TabIndex = 6;
      this.label3.Text = "Password Box";
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(408, 221);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {this.btnPasswordDecoderRing,
                                      this.label3,
                                      this.passwordBox,
                                      this.label2,
                                      this.capsOnlyBox,
                                      this.btnGetMultiLineText,
                                      this.label1,
                                      this.multiLineBox});
      this.Text = "TextBox Types";

    }

    protected void btnPasswordDecoderRing_Click (object sender, System.EventArgs e)
    {
      MessageBox.Show(passwordBox.Text, "Your password is:");
    }

    protected void btnGetMultiLineText_Click (object sender, System.EventArgs e)
    {
      MessageBox.Show(multiLineBox.Text, "Here is your text");
    }

        public static void Main(string[] args) 
        {
            Application.Run(new TextForm());
        }
    }