如何在运行时在Visual Studio C#中创建标签?我有这个:在运行时添加标签
Label test = new Label();
test.Location = new Point(1,1);
test.Text = "Working";
但它没有显示出来。我见过像这样使用:
Controls.Add(test);
但我刚刚得到的错误:The name 'Controls' does not exist in the current context
编辑:
public override void OnCollision()
{
Label test = new Label();
test.Location = new Point(1,1);
test.Text = "Working";
test.Enabled = true;
this.Controls.Add(test);
}
一个按钮被按下时的方法运行。
你在哪里添加这个标签? – 2013-11-23 22:22:11