c#中button的坐标问题
怎么样使BUtton按钮在鼠标移至它上面时向下移动离开后回到原来的位置我的代码是这样的privatevoidbtnKeHuGenJin_MouseLeave(object...
怎么样使BUtton按钮在鼠标移至它上面时向下移动离开后回到原来的位置
我的代码是这样的
private void btnKeHuGenJin_MouseLeave(object sender, EventArgs e)
{
int b = Convert.ToInt32(btnKeHuGenJin.Top) +3;
int a = Convert.ToInt32(btnKeHuGenJin.Location.X);
btnKeHuGenJin.Location = new Point(a, b);
//btnKeHuGenJin.Top = b;
//btnKeHuGenJin.Left = a;
}
private void btnKeHuGenJin_MouseMove_1(object sender, MouseEventArgs e)
{
int b = Convert.ToInt32(btnKeHuGenJin.Location.Y) - 3;
int a = Convert.ToInt32(btnKeHuGenJin.Location.X);
btnKeHuGenJin.Location = new Point(a, b);
}
运行后怎么没有恢复到原来的位置 展开
我的代码是这样的
private void btnKeHuGenJin_MouseLeave(object sender, EventArgs e)
{
int b = Convert.ToInt32(btnKeHuGenJin.Top) +3;
int a = Convert.ToInt32(btnKeHuGenJin.Location.X);
btnKeHuGenJin.Location = new Point(a, b);
//btnKeHuGenJin.Top = b;
//btnKeHuGenJin.Left = a;
}
private void btnKeHuGenJin_MouseMove_1(object sender, MouseEventArgs e)
{
int b = Convert.ToInt32(btnKeHuGenJin.Location.Y) - 3;
int a = Convert.ToInt32(btnKeHuGenJin.Location.X);
btnKeHuGenJin.Location = new Point(a, b);
}
运行后怎么没有恢复到原来的位置 展开
1个回答
展开全部
int MoveJL=10;
int OldTop;
private void button1_MouseMove(object sender, MouseEventArgs e)
{
button1.Top = OldTop+MoveJL;
}
private void Form1_Load(object sender, EventArgs e)
{
OldTop = button1.Top;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
button1.Top = OldTop;
}
int OldTop;
private void button1_MouseMove(object sender, MouseEventArgs e)
{
button1.Top = OldTop+MoveJL;
}
private void Form1_Load(object sender, EventArgs e)
{
OldTop = button1.Top;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
button1.Top = OldTop;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询