Wrox Programmer Forums
|
BOOK: Beginning Object-Oriented Programming with C#
This is the forum to discuss the Wrox book Beginning Object-Oriented Programming with C# by Jack Purdum; ISBN: 978-1-1183-3692-2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Object-Oriented Programming with C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2015, 03:00 PM
Registered User
 
Join Date: Feb 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 2 Program 1 - Blank window on run

Hi. I am trying to do a test run of Chapter02Program01. I've added the code and created a label, textbox and button per the instructions. But when I do F5, a blank window is displayed. The label, textbox and button do not even display. I've actually entered a title for the window in the frmMain Text property and resized it but it does not display with the title or the new size.

I am running VS 2013 on Windows 7 (via Bootcamp on a Mac), so I'm not sure if that's the issue. My code is below. Please let me know if I'm missing anything. Thanks.

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

public class frmMain:Form
{
    private TextBox txtName;
    private Button btnSubmit;
    private Label lblName;
#region Windows Code
    private void IntializeComponent()
    {
    }
#endregion
    public frmMain()
    {
        IntializeComponent();
    }
    [STAThread]
    public static void Main()
    {
        frmMain main = new frmMain();
        Application.Run(main);
    }

    private void InitializeComponent()
    {
            this.lblName = new System.Windows.Forms.Label();
            this.txtName = new System.Windows.Forms.TextBox();
            this.btnSubmit = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // lblName
            // 
            this.lblName.AutoSize = true;
            this.lblName.Location = new System.Drawing.Point(48, 131);
            this.lblName.Name = "lblName";
            this.lblName.Size = new System.Drawing.Size(55, 20);
            this.lblName.TabIndex = 0;
            this.lblName.Text = "Name:";
            this.lblName.Click += new System.EventHandler(this.label1_Click);
            // 
            // txtName
            // 
            this.txtName.Location = new System.Drawing.Point(109, 128);
            this.txtName.Name = "txtName";
            this.txtName.Size = new System.Drawing.Size(192, 26);
            this.txtName.TabIndex = 1;
            // 
            // btnSubmit
            // 
            this.btnSubmit.Location = new System.Drawing.Point(307, 124);
            this.btnSubmit.Name = "btnSubmit";
            this.btnSubmit.Size = new System.Drawing.Size(98, 34);
            this.btnSubmit.TabIndex = 2;
            this.btnSubmit.Text = "Submit";
            this.btnSubmit.UseVisualStyleBackColor = true;
            this.btnSubmit.Click += new System.EventHandler(this.button1_Click);
            // 
            // frmMain
            // 
            this.ClientSize = new System.Drawing.Size(835, 586);
            this.Controls.Add(this.lblName);
            this.Controls.Add(this.txtName);
            this.Controls.Add(this.btnSubmit);
            this.Name = "frmMain";
            this.Text = "Main Form";
            this.ResumeLayout(false);
            this.PerformLayout();

    }

    private void label1_Click(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        frmMain.ActiveForm.Text = txtName.Text;
    }
}
 
Old February 11th, 2015, 04:26 PM
Registered User
 
Join Date: Feb 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default RESOLVED

NM. I fixed it.

I had made several previous attempts at creating this form and I believe the latest iteration was somehow referencing one of the old ones. I deleted all of the projects and started over from scratch. It now runs and display properly.

Alex





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to program from excel to enter information in the next blank cell k_babb BOOK: Beginning Visual C# 2010 0 September 11th, 2011 01:54 PM
Closing a Blank Leftover Window Heff Perl 2 May 12th, 2008 04:45 PM
Pg. 41: Properties Window Blank SomeoneKnows BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 3 September 28th, 2007 10:16 AM
program to run before window shutdown? rocky0893 VB How-To 0 June 20th, 2007 05:33 AM
Blank Property window... aoskayak BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 3 May 5th, 2006 11:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.