这个是相关链接你能去看看下。作者: shetaikeng 时间: 2010-1-14 11:01 AM 标题: 回复 #7 宅男-兜着走 的帖子 你说的这些大致上我还能理解
但是我不理解的就是
我刚做了一个新的CODE
namespace mini_3rd_try
{
public partial class Form1 : Form
{
private System.Windows.Forms.CheckBox[] _chkArray;
public Form1()
{
InitializeComponent();
}
private void ChkForm(object sender, System.EventArgs e)
{
_chkArray = new CheckBox[]
{
chkA1,
chkB1,chkB2,
chkC1,chkC2,chkC3,
chkD1,chkD2,chkD3,chkD4,
chkE1,chkE2,chkE3,chkE4,chkE5,
};
for (int i = 0; i < 15; i++)
this._chkArray.Click += new System.EventHandler(this.Click);
}
private void rulesToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("1.The player can strike the sticks horizontally." + "\n" +
"2.The player can strike the stick next to the adjacent stick and so on after he/she has chosen a stick from that particular row" + "\n" +
"3.The player who strike the last stick is the loser", "Game Intro");
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult DialogResult;
DialogResult = MessageBox.Show("Are you sure you are closing?", "closing", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (DialogResult == DialogResult.Yes)
{
Close();
}
}
private void btnPlayer_Click(object sender, EventArgs e)
{
Game();
}
private void Game()
{
int i;
if (btnPlayer.Text == "Start")
{
Color1();
Color2();
btnPlayer.Text = "Player 1";
for (i = 0; i < 15; i++)
{
_chkArray.Enabled = true;
}
}
else if (btnPlayer.Text == "Player 1")
{
btnPlayer.Text = "Player 2";
}
else if (btnPlayer.Text == "Player 2")
{
btnPlayer.Text = "Player 1";
}
Endturn();
btnRestart.Visible = true;
}
private void btnRestart_Click(object sender, EventArgs e)
{
int i = 0;
for (i = 0; i < 15; i++)
{
_chkArray.Checked = false;
}
Game();
CheckColor();
}
private void CheckColor()
{
if (lblPlayer1.BackColor == lblPlayer2.BackColor)
{
MessageBox.Show("Player 1 and Player 2 Cant have the same colour");
lblPlayer1.BackColor = Color.White;
lblPlayer2.BackColor = Color.White;
Color1();
Color2();
}
}
private void Endturn()
{
int i;
for (i = 0; i < 15; i++)
{
if (_chkArray.Checked == true)
{
_chkArray.Enabled = false;
}
}
}
private void colorme(int i)
{
if (_chkArray.Checked == true)
{
if (btnPlayer.Text == "Player 1")
{
_chkArray.BackColor = colorDialog1.Color;
}
else if (btnPlayer.Text == "Player 2")
{
_chkArray.BackColor = colorDialog2.Color;
}
}
else
{
_chkArray.BackColor = Color.FloralWhite;
}
}
}
}
但是有问题
就是但我要运行的时候
Error 1 The event 'System.Windows.Forms.Control.Click' can only appear on the left hand side of += or -=
就是红色字的那个