View Single Post
  #1 (permalink)  
Old March 9th, 2009, 10:07 PM
sprdave sprdave is offline
Authorized User
 
Join Date: Apr 2007
Location: Meridian, ID, USA.
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default Form Data Will Not Display When I Click On Display Button

Hello,

I have followed the books instructions, and the Errata, and still cannot get any DATA to display from the "Mailing Label Program". I fill in all of the fields and click the "Display Button" The button changes and says "Mail Label" but no DATA is displayed in the textbox from the fields. What am I doing wrong???? Here is my code: Thanks, in advance

using System;
using System.Windows.Forms;

public class frmMain : Form
{
private Label label1;
private Label label2;
private Label label4;
private Label label5;
private TextBox txtName;
private TextBox txtAddress;
private TextBox txtCity;
private TextBox txtState;
private TextBox txtZip;
private Button btnDisplayOutput;
private Button btnExit;
private TextBox txtResult;
private Label label3;
#region Windows code
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtAddress = new System.Windows.Forms.TextBox();
this.txtCity = new System.Windows.Forms.TextBox();
this.txtState = new System.Windows.Forms.TextBox();
this.txtZip = new System.Windows.Forms.TextBox();
this.btnDisplayOutput = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.txtResult = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(63, 41);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(75, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Name:";
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(63, 83);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 20);
this.label2.TabIndex = 1;
this.label2.Text = "Address:";
//
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label3.Location = new System.Drawing.Point(60, 130);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 20);
this.label3.TabIndex = 2;
this.label3.Text = "City";
//
// label4
//
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label4.Location = new System.Drawing.Point(258, 130);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(40, 20);
this.label4.TabIndex = 3;
this.label4.Text = "State";
//
// label5
//
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Location = new System.Drawing.Point(376, 130);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(40, 20);
this.label5.TabIndex = 4;
this.label5.Text = "Zip";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(181, 40);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(411, 20);
this.txtName.TabIndex = 5;
//
// txtAddress
//
this.txtAddress.Location = new System.Drawing.Point(181, 82);
this.txtAddress.Name = "txtAddress";
this.txtAddress.Size = new System.Drawing.Size(411, 20);
this.txtAddress.TabIndex = 6;
//
// txtCity
//
this.txtCity.Location = new System.Drawing.Point(141, 130);
this.txtCity.Name = "txtCity";
this.txtCity.Size = new System.Drawing.Size(111, 20);
this.txtCity.TabIndex = 7;
//
// txtState
//
this.txtState.Location = new System.Drawing.Point(304, 130);
this.txtState.Name = "txtState";
this.txtState.Size = new System.Drawing.Size(54, 20);
this.txtState.TabIndex = 8;
//
// txtZip
//
this.txtZip.Location = new System.Drawing.Point(434, 129);
this.txtZip.Name = "txtZip";
this.txtZip.Size = new System.Drawing.Size(158, 20);
this.txtZip.TabIndex = 9;
//
// btnDisplayOutput
//
this.btnDisplayOutput.Location = new System.Drawing.Point(60, 217);
this.btnDisplayOutput.Name = "btnDisplayOutput";
this.btnDisplayOutput.Size = new System.Drawing.Size(75, 23);
this.btnDisplayOutput.TabIndex = 10;
this.btnDisplayOutput.Text = "&Display";
this.btnDisplayOutput.UseVisualStyleBackColor = true;
this.btnDisplayOutput.Click += new System.EventHandler(this.btnDisplayOutput_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(517, 217);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 23);
this.btnExit.TabIndex = 11;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(60, 262);
this.txtResult.Multiline = true;
this.txtResult.Name = "txtResult";
this.txtResult.ReadOnly = true;
this.txtResult.Size = new System.Drawing.Size(532, 194);
this.txtResult.TabIndex = 12;
//
// frmMain
//
this.ClientSize = new System.Drawing.Size(635, 468);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnDisplayOutput);
this.Controls.Add(this.txtZip);
this.Controls.Add(this.txtState);
this.Controls.Add(this.txtCity);
this.Controls.Add(this.txtAddress);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;
this.Text = "Mailing Label Program";
this.Load += new System.EventHandler(this.frmMain_Load);
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

public frmMain()
{
InitializeComponent();
}

public static void Main()
{
frmMain main = new frmMain();
Application.Run(main);
}

private void frmMain_Load(object sender, EventArgs e)
{

}

private void btnDisplayOutput_Click(object sender, EventArgs e)
{
String buffer;

buffer = "Mailing Label:" + Environment.NewLine +
Environment.NewLine;
buffer = buffer + " Name: " + txtName.Text +
Environment.NewLine;
buffer = buffer + "Address: " + txtAddress.Text +
Environment.NewLine;
buffer = buffer + " City: " + txtCity.Text +
" State: " + txtState.Text +
" Zip: " + txtZip.Text;
btnDisplayOutput.Text = buffer;

}
}
__________________
SUPER DAVE