GameBuilder
GameBuilder

Reputation: 1189

Button not displayed in C# Windows Form Application

I am trying to develop Windows Form Application using Visual Studio 2010.

I drag the buttons from toolbox on Form 1

enter image description here

After running the Aplication i am getting this output.

enter image description here

I dont see any button on the screen.

I tried Bring to front property , I checked the code also button is add in the form.

private void InitializeComponent()
{
    this.button1 = new System.Windows.Forms.Button();
    this.button2 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(316, 62);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(75, 23);
    this.button1.TabIndex = 0;
    this.button1.Text = "button1";
    this.button1.UseVisualStyleBackColor = true;
    // 
    // button2
    // 
    this.button2.Location = new System.Drawing.Point(184, 118);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(75, 23);
    this.button2.TabIndex = 1;
    this.button2.Text = "fdefdf";
    this.button2.UseVisualStyleBackColor = true;
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(439, 170);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false);
}

Upvotes: 0

Views: 11454

Answers (2)

rjps12
rjps12

Reputation: 605

Have you tried to put this code in page_load?

button1.Visible = true;
button2.Visible = true;

Upvotes: 1

Kalikovision
Kalikovision

Reputation: 36

I believe the answer to this one might be simple in this particular case:

  • The buttons are positioned outside of the form. The form is, lets say, 300x200 and the buttons are likely positioned at beyond those bounds.

I'm only responding to this because I wasn't sure if it was related to my issue or not, but it appears not to be.

Upvotes: 0

Related Questions