我想创建标签和使用方法设置文本,但它不会工作,这是我的代码:方法来创建和更改标签
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