Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / August 2003

Tip: Looking for answers? Try searching our database.

Newbie: Button does not show (C#)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Spiegel - 12 Aug 2003 14:21 GMT
Hi all,

I've got the code shown at the end.  When I compile and run the form from
the CLI, a blank form shows (no button is visible).  What's my newbie
mistake???

TIA,

John

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

public class CalculatorForm : Form
{
private Container Components;
private Button    btnCalculate;

   public void CaclulatorForm()
   {
       InitializeComponent();
   }

private void InitializeComponent()
{
 Components = new Container();
 btnCalculate = new Button();

       btnCalculate.Text     = "Calculate";
       btnCalculate.Click   +=
           new EventHandler (btnCalculate_Click);
       btnCalculate.Location = new Point(94, 80);
       btnCalculate.Size     = new Size(75, 23);
       btnCalculate.TabIndex = 0;
       btnCalculate.Visible  = true;
 Controls.Add(btnCalculate);

}

protected void btnCalculate_Click (object sender,
                                      System.EventArgs e)
{
}

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

}
nicolasr - 12 Aug 2003 14:52 GMT
Hi John,
there is a typo in your constructor. And it shouldn't have a return value
(remove the 'void'). I think the problem is just that because of the typo no
constructor is found and thus InitializeComponent() never gets called.

hope this helps,
Nick
Willy Denoyette [MVP] - 12 Aug 2003 14:59 GMT
|| Hi all,
||
[quoted text clipped - 7 lines]
||
|| using System;
....
||  private Button    btnCalculate;
||
||     public void CaclulatorForm()
||     {
||         InitializeComponent();
||     }
}

   public CalculatorForm()
   {
       ...

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.