View Single Post
  #9 (permalink)  
Old February 12th, 2011, 03:53 PM
scolty scolty is offline
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 2
Thanked 0 Times in 0 Posts
Default Same problem as above

Good evening, im also experiencing similar problems. I have, to the best of my knowledge managed to correct the code according to the Errata posts yet neither of my buttons (referring to the code, not myself) are working. Ive already copied the original posts code and scanned through it + couldnt see any differences other than i have made the alterations stated in the Errata.

If someone would be willing to have a look at this and point out my stupid mistake id appreciate it as ive already spent a good few hours starting from scratch a couple time.

Code:
using System;
using System.Windows.Forms;

public class frmMain : Form
{
    private Label label1;
    private Label label2;
    private Label label4;
    private Label label5;
    private TextBox txtCity;
    private TextBox txtName;
    private TextBox txtAddress;
    private TextBox txtState;
    private TextBox txtZip;
    private Button btnDisplayOutput;
    private Button btnExit;
    private TextBox txtDisplayOutput;
    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.txtCity = new System.Windows.Forms.TextBox();
        this.txtName = new System.Windows.Forms.TextBox();
        this.txtAddress = 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.txtDisplayOutput = new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        // 
        // label1
        // 
        this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.label1.Location = new System.Drawing.Point(0, 0);
        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(-3, 20);
        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(-3, 40);
        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(-3, 60);
        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(-3, 80);
        this.label5.Name = "label5";
        this.label5.Size = new System.Drawing.Size(40, 20);
        this.label5.TabIndex = 4;
        this.label5.Text = "Zip:";
        // 
        // txtCity
        // 
        this.txtCity.Location = new System.Drawing.Point(81, 40);
        this.txtCity.Name = "txtCity";
        this.txtCity.Size = new System.Drawing.Size(100, 20);
        this.txtCity.TabIndex = 7;
        // 
        // txtName
        // 
        this.txtName.Location = new System.Drawing.Point(81, 0);
        this.txtName.Name = "txtName";
        this.txtName.Size = new System.Drawing.Size(100, 20);
        this.txtName.TabIndex = 5;
        // 
        // txtAddress
        // 
        this.txtAddress.Location = new System.Drawing.Point(81, 20);
        this.txtAddress.Name = "txtAddress";
        this.txtAddress.Size = new System.Drawing.Size(100, 20);
        this.txtAddress.TabIndex = 6;
        // 
        // txtState
        // 
        this.txtState.Location = new System.Drawing.Point(46, 61);
        this.txtState.Name = "txtState";
        this.txtState.Size = new System.Drawing.Size(100, 20);
        this.txtState.TabIndex = 8;
        // 
        // txtZip
        // 
        this.txtZip.Location = new System.Drawing.Point(46, 79);
        this.txtZip.Name = "txtZip";
        this.txtZip.Size = new System.Drawing.Size(100, 20);
        this.txtZip.TabIndex = 9;
        // 
        // btnDisplayOutput
        // 
        this.btnDisplayOutput.Location = new System.Drawing.Point(0, 114);
        this.btnDisplayOutput.Name = "btnDisplayOutput";
        this.btnDisplayOutput.Size = new System.Drawing.Size(75, 23);
        this.btnDisplayOutput.TabIndex = 11;
        this.btnDisplayOutput.Text = "&Display";
        this.btnDisplayOutput.UseVisualStyleBackColor = true;
        // 
        // btnExit
        // 
        this.btnExit.Location = new System.Drawing.Point(120, 114);
        this.btnExit.Name = "btnExit";
        this.btnExit.Size = new System.Drawing.Size(75, 23);
        this.btnExit.TabIndex = 12;
        this.btnExit.Text = "E&xit";
        this.btnExit.UseVisualStyleBackColor = true;
        // 
        // txtDisplayOutput
        // 
        this.txtDisplayOutput.Location = new System.Drawing.Point(28, 174);
        this.txtDisplayOutput.Multiline = true;
        this.txtDisplayOutput.Name = "txtDisplayOutput";
        this.txtDisplayOutput.ReadOnly = true;
        this.txtDisplayOutput.Size = new System.Drawing.Size(202, 71);
        this.txtDisplayOutput.TabIndex = 13;
        // 
        // frmMain
        // 
        this.ClientSize = new System.Drawing.Size(292, 266);
        this.Controls.Add(this.txtDisplayOutput);
        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.CenterScreen;
        this.Text = "Mailing Label Program";
        this.ResumeLayout(false);
        this.PerformLayout();

    }
    #endregion

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

    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;
        txtDisplayOutput.Text = buffer;
    }
    private void btnExit_Click(object sender, EventArgs e)
    {
        Close();
    }

    
}