How can show data from another form
- by Michael Quiles
This is basically a tic tac toe game, and I have another form called Winner.cs when a player wins I want it to call the form (this part works) and then I want it to say xWinner.label =b1.text"" + has won the game!. the part I cant get to work is displaying the text in the winners form label. There's an example of a message box that commented out for reference
instead of b1.text
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyGame
{
public class Result1
{
static private int[,] Winners = new int[,]
{
{0,1,2},
{3,4,5},
{6,7,8},
{0,3,6},
{1,4,7},
{2,5,8},
{0,4,8},
{2,4,6},
};
static public bool CheckWinner(Button[] myControls)
{
bool gameOver = false;
for (int i = 0; i < 8; i++)
{
int a = Winners[i, 0], b = Winners[i, 1], c = Winners[i, 2];
Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c];
if (b1.Text == "" || b2.Text == "" || b3.Text == "")
continue;
if (b1.Text == b2.Text && b2.Text == b3.Text)
{
b1.BackColor = b2.BackColor = b3.BackColor = System.Drawing.Color.LightCoral;
b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
gameOver = true;
Form xWinnerForm = new xWinnerForm();
xWinnerForm.Show();
//MessageBox.Show(b1.Text + " .... Wins the game!", "Game End", MessageBoxButtons.OK);
//break;
}
}
return gameOver;
}
}
}