亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我無法為 CodeDom 編譯的應用程序創建標簽

我無法為 CodeDom 編譯的應用程序創建標簽

C#
慕萊塢森 2022-01-16 15:09:29
我用codedom制作了一個簡單的表單編譯器。一切都很好,表單運行良好,但我可以創建一個“標簽”,這是我的應用程序的反編譯代碼:using System;using System.Drawing;using System.Windows.Forms;namespace Neutron{public class NeutronX : Form{    private static void Main()    {        Application.EnableVisualStyles();        Application.SetCompatibleTextRenderingDefault(false);        Application.Run(new NeutronX());    }    public NeutronX()    {        this.InitializeComponent();    }    private void InitializeComponent()    {        this.label1 = new Label();        base.SuspendLayout();        base.AutoScaleDimensions = new SizeF(6f, 13f);        base.AutoScaleMode = AutoScaleMode.Font;        this.BackColor = Color.FromArgb(255, 255, 255);        base.ClientSize = new Size(400, 378);        base.MaximizeBox = false;        base.Name = "Form";        base.ShowIcon = false;        this.Text = "Form";        this.ForeColor = Color.Black;        base.ResumeLayout(false);        base.PerformLayout();        this.label1.AutoSize = true;        this.label1.Location = new Point(187, 62);        this.label1.Name = "label1";        this.label1.Size = new Size(49, 21);        this.label1.TabIndex = 0;        this.label1.Text = "label1";        this.label1.TextAlign = ContentAlignment.TopLeft;        this.label1.BackColor = Color.FromArgb(255, 128, 64);        this.label1.ForeColor = Color.FromArgb(0, 0, 0);        this.label1.Visible = true;    }    public Label label1;   }}我究竟做錯了什么?我測試了一切,但一無所獲......
查看完整描述

1 回答

?
SMILET

TA貢獻1796條經驗 獲得超4個贊

只是把它作為答案。僅創建控件是不夠的,您需要將其添加到控件樹以由消息循環顯示和處理。在您的情況下,表單控制列表。只需添加:

 this.Controls.Add(this.label1);


查看完整回答
反對 回復 2022-01-16
  • 1 回答
  • 0 關注
  • 159 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號