我想創建標籤和使用方法設置文本,但它不會工作,這是我的代碼:方法來創建和更改標籤
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
intro();
}
private void fullScreen()
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Bounds = Screen.PrimaryScreen.Bounds;
}
private void intro()
{
pictureBox1.BackColor = Color.White;
pictureBox1.SendToBack();
Label introInfo = new Label();
introInfo.Font = new Font("century gothic", 24, FontStyle.Bold);
introInfo.ForeColor = Color.Cyan;
introInfo.Text = "succes bro!";
introInfo.Visible = true;
introInfo.Location = new Point(100, 100);
}
}
我應該怎麼做,使其工作?
哪裏我應該添加this.Controls.Add(label); ? – notAdmin
用代碼示例更新了答案。 – Marko
是這樣的? 'private void intro() { pictureBox1.BackColor = Color.White; pictureBox1.SendToBack(); Label introInfo = new Label(); introInfo.Font = new Font(「世紀哥特式」,24,FontStyle.Bold); introInfo.ForeColor = Color.Cyan; introInfo.Text =「succes bro!」; introInfo.Visible = true; introInfo.Location = new Point(100,100); this.Controls.Add(introInfo); }' – notAdmin