如何在運行時在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