想添加一个鼠标移动到按钮上替换背景图的事件。
可是提示我不能隐性转换。
看了一些书,都还是基础的基础。
明白这里是类型不通用。 我的代码如下。 请朋友给个方法。代码我会自己敲。呵呵。谢谢大家。 private void ConnectBotton_MouseOver(object sender, EventArgs e)
{
this.BackgroundImage= "botton.png";
}
可是提示我不能隐性转换。
看了一些书,都还是基础的基础。
明白这里是类型不通用。 我的代码如下。 请朋友给个方法。代码我会自己敲。呵呵。谢谢大家。 private void ConnectBotton_MouseOver(object sender, EventArgs e)
{
this.BackgroundImage= "botton.png";
}
如果是button 大概是((button)sender).BackgroundImage= "botton.png";
不可以这样写this.BackgroundImage= "botton.png"; private void button1_MouseHover(object sender, EventArgs e)
{
this.BackgroundImage = Bitmap.FromFile("h:\\test.jpg");
}
这问题延续了一点。希望各位能够耐心的帮我,谢谢了。1.lxcnn(过客) 你的代码我试过了。 期间的控件名称那个我都替换为自己的命名。
但是效果不出来。 鼠标滑过。替换按钮背景图。
2.在我这个项目中,我已经引入了几个图片 png格式。 现在显示正常(就是form load后默认的背景图) 但是我看代码没有 c:\\XX.png之类的代码。 在添加这些背景图的时候,我看到都是从Resources.resx 引入的。 如系统这种,我应该怎么才能实现呢?
{
this.BackgroundImage = imageList1.Images["test.png"];
}