在VS中,picturebox里的图片在鼠标移过的时候改变成另一张图片,这样的代码怎么写呢?
3个回答
展开全部
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
pictureBox1.ImageLocation = "移过时要显示的图像文件的路径";
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "原来图像文件的路径";
}
{
pictureBox1.ImageLocation = "移过时要显示的图像文件的路径";
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "原来图像文件的路径";
}
追问
出错了,说没有ImageLocation的定义。怎么办呢?
追答
你检查一下图像文件的路径有没有写错,例如·pictureBox1.ImageLocation = @"D:\我的文档\My Pictures\10.gif";
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
展开全部
//获得当前项目运行的路径,image文件夹应该放在Debug这个文件夹中
path = System.IO.Directory.GetCurrentDirectory();
private void pictureBox1_MouseHover(object sender, EventArgs e)
{
this.pictureBox1.Image=System.Drawing.Image.FromFile(path + @"\images\CloseButton_Hover.bmp");
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
this.pictureBox1.Image = System.Drawing.Image.FromFile(path + @"\images\CloseButton_Down.bmp");
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
this.pictureBox1.Image = System.Drawing.Image.FromFile(path + @"\images\CloseButton_Normal.bmp");
}
path = System.IO.Directory.GetCurrentDirectory();
private void pictureBox1_MouseHover(object sender, EventArgs e)
{
this.pictureBox1.Image=System.Drawing.Image.FromFile(path + @"\images\CloseButton_Hover.bmp");
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
this.pictureBox1.Image = System.Drawing.Image.FromFile(path + @"\images\CloseButton_Down.bmp");
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
this.pictureBox1.Image = System.Drawing.Image.FromFile(path + @"\images\CloseButton_Normal.bmp");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哪就查看api有没有鼠标事件这样函数!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询