日期:2014-05-18 浏览次数:21074 次
private void pnl_MouseDown(object sender, MouseEventArgs e)
{
chsman[nMousePositionOnChessboardX,nMousePositionOnChessboardY]=new Chessman();
}//nMousePostionOnChessboardX代表按钮在panel上的位置,它乘以50就是按钮的Location.X,Location.Y同理
private void InitializeComponent()
{
this.SuspendLayout();
//
// Chessman
//
this.Name = "Chessman";
//this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Chessman_MouseClick);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Chessman_Paint);
this.ResumeLayout(false);
this.Location = new Point(FormChessboard.nMousePositionOnChessboardX*nChessmanSizeWidth,
FormChessboard.nMousePositionOnChessboardY*nChessmanSizeHeight);
this.Size = new Size(nChessmanSizeWidth,nChessmanSizeHeight);
Color clr = Color.FromArgb(255, 255, 255);
this.BackColor = clr;
this.BackgroundImage = global::ball2.Properties.Resources.Rad;
// 我想把按钮的背景图片设置成Rad(已经存在的资源位图)
// 报错如下:Error1' ball2.Properties.Resources' does not contain a definition for 'Rad'
pnl.Controls.Add(this);
//现在轮到把按钮添加到formChessboard.pnl上,可是提示我pnl不存在
//写成formChessboard.pnl.Controls.Add(this),提示我不是静态的
//把那个pnl定义改成static时,formChessboard类初始化pnl又有错误:
//Static member 'ball2.FormChessboard.pnl' cannot be accessed with an instance reference;
qualify it with a type name instead
}