我做了一個簡單的tic,tac,toe遊戲。我有兩種形式,Form1
和frmStats
。在我的frmStats
我有一個標籤lblDraw
。 我想要它,所以當玩家進入平局時,標籤會增加1。如何訪問Form1
的代碼?從另一種形式訪問控件值
我Form 1代碼:
if (winner != 0)
this.Text = String.Format("Player {0} Wins!", winner);
else if (winner == 0 && turnCounter == 9)
this.Text = "Draw!";
//this is where i want/think the code should be to change the label
else
...
將公共標籤'lblDraw'的修飾符設置爲公共。 –
我有這個,但它不會在form1中工作:public Stats() { InitializeComponent(); System.Windows.Forms.Label lblDraw; – KangarooRider
沒有不喜歡那..檢查我的答案。 –