展开全部
//顺时针动的:
void btnMove_Click(object sender,EventArgs e){
lb1Logo.Left=0;
lb1Logo.Top=0;
Timer.Enabled=true;
}
int moveD=1;
const int MoveUp=0;
const int MoveRight=1;
const int MoveDown=2;
const int MoveLeft=3;
void Timer_Tick(object sender,EventArgs e){
switch (moveD){
case MoveUp:
lb1Logo.Top-=10;
if(lb1Logo.Top<0){
lb1Logo.Top=0;
moveD++;
}
break;
case MoveRight:
lb1Logo.Left+=10;
if(lb1Logo.Right>this.Width){
lb1Logo.Right=this.Width;
moveD++;
}
break;
case MoveDown:
lb1Logo.Top+=10;
if(lb1Logo.Bottom>this.Height){
lb1Logo.Top=this.Height;
moveD++;
}
break;
case MoveLeft:
lb1Logo.Left-=10;
if(lb1Logo.Left<0){
lb1Logo.Left=0;
moveD=MoveUp;
}
break;
}
}
追问
case MoveRight:
lb1Logo.Left+=10;
if(lb1Logo.Right>this.Width){
lb1Logo.Right=this.Width; // lb1Logo.Right ,这里无法被赋值是怎么回事
追答
lb1Logo.Left=this.Width-lb1Logo.Width;
展开全部
您好,您这样:bool isdown;//鼠标左键是否按下
Point mousepos;//鼠标位置
private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isdown = true;//鼠标按下
}
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (isdown)
{
mousepos.Offset(e.X , e.Y);
this.label1.Location = mousepos;//label控件的位置
}
}
private void label1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
isdown = false;//释放鼠标左键
}
Point mousepos;//鼠标位置
private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isdown = true;//鼠标按下
}
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (isdown)
{
mousepos.Offset(e.X , e.Y);
this.label1.Location = mousepos;//label控件的位置
}
}
private void label1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
isdown = false;//释放鼠标左键
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |