- 分享
- 0
- 人气
- 0
- 主题
- 5
- 帖子
- 322
- UID
- 14148
- 积分
- 1733
- 阅读权限
- 19
- 注册时间
- 2005-6-14
- 最后登录
- 2016-6-23
- 在线时间
- 239 小时
|
回复 #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();
}
private void Color1()
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
lblPlayer1.BackColor = colorDialog1.Color;
}
else
{
MessageBox.Show("Player 1 will use default Blue", "Player 1");
lblPlayer1.BackColor = Color.Blue;
colorDialog1.Color = Color.Blue;
}
CheckColor();
}
private void Color2()
{
if (colorDialog2.ShowDialog() == DialogResult.OK)
{
lblPlayer2.BackColor = colorDialog2.Color;
}
else
{
MessageBox.Show("Player 2 will use default Red", "Player 2");
lblPlayer2.BackColor = Color.Red;
colorDialog2.Color = Color.Red;
}
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 -=
就是红色字的那个
[ 本帖最后由 shetaikeng 于 2010-1-14 02:51 PM 编辑 ] |
|