Advertisement

05.01.2008 at 01:16PM PDT, ID: 23369901
[x]
Attachment Details

C# display text from textbox in label

Asked by 9apit in Microsoft Visual C#.Net, C# Programming Language

Tags: C#, windows

Good afternoon expert,
Seems like such a simple thing. When a button is clicked the text from user input at textbox is display as a label.
Been working on for two hours and still cannot get it to go. Thanks. Allen
PS getting error message
'System.Windows.Forms.Control.text' is inaccessible due to its protection level

Code

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace text_from_textbox
{
      public class Form1 : System.Windows.Forms.Form
      {
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.TextBox textBox1;
            private System.Windows.Forms.Label label1;
            private System.ComponentModel.Container components = null;
            public Form1()
            {
                  // Required for Windows Form Designer support
            InitializeComponent();
            }
            /// Clean up any resources being used.
            protected override void Dispose( bool disposing )
            {
                  if( disposing )
                  {
                        if (components != null)
                        {
                              components.Dispose();
                        }
                  }
                  base.Dispose( disposing );
            }
            #region Windows Form Designer generated code
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            private void InitializeComponent()
            {
                  this.button1 = new System.Windows.Forms.Button();
                  this.textBox1 = new System.Windows.Forms.TextBox();
                  this.label1 = new System.Windows.Forms.Label();
                  this.SuspendLayout();
                  // button1
                  this.button1.Location = new System.Drawing.Point(72, 88);
                  this.button1.Name = "button1";
                  this.button1.TabIndex = 0;
                  this.button1.Text = "button1";
                  this.button1.Click += new System.EventHandler(this.button1_Click);
                  // textBox1
                        this.textBox1.Location = new System.Drawing.Point(48, 32);
                  this.textBox1.Name = "textBox1";
                  this.textBox1.TabIndex = 1;
                  this.textBox1.Text = "textBox1";
                  //
                  // label1
                  //
                  this.label1.Location = new System.Drawing.Point(64, 168);
                  this.label1.Name = "label1";
                  this.label1.TabIndex = 2;
                  this.label1.Text = "label1";
                  //
                  // Form1
                  //
                  this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
                  this.ClientSize = new System.Drawing.Size(292, 266);
                  this.Controls.Add(this.label1);
                  this.Controls.Add(this.textBox1);
                  this.Controls.Add(this.button1);
                  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());
            }

            private void button1_Click(object sender, System.EventArgs e)
            {
                  label1.Text = textBox1.text;
            }
      }
}

Start Free Trial
[+][-]05.01.2008 at 01:28PM PDT, ID: 21482413

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, C# Programming Language
Tags: C#, windows
Sign Up Now!
Solution Provided By: Hendo1973
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.01.2008 at 01:28PM PDT, ID: 21482420

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.01.2008 at 01:28PM PDT, ID: 21482424

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 01:29PM PDT, ID: 21482427

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628