繁体   English   中英

在C#Windows窗体应用程序中未显示按钮

[英]Button not displayed in C# Windows Form Application

我正在尝试使用Visual Studio 2010开发Windows窗体应用程序。

我从窗体1的工具箱中拖动按钮

在此处输入图片说明

运行Aplication之后,我得到了这个输出。

在此处输入图片说明

我在屏幕上看不到任何按钮。

我尝试了Bring to front property,我检查了代码,并且按钮也添加到了表单中。

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);

    }

您是否尝试过将此代码放入page_load中?

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

我相信在这种特殊情况下,对这个问题的答案可能很简单:

  • 这些按钮位于表单外部。 可以说格式为300x200,按钮的位置可能超出了这些范围。

我之所以只是对此做出回应,是因为我不确定这是否与我的问题有关,但似乎与我的问题无关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM