我有init
有背景。现在我需要更改RadioButton
事件的背景。我可以用
MouseEnter
但我已经将该图像作为项目中的资源,我不知道如何实现它。
答案 0 :(得分:1)
尝试如下: -
private void button_MouseEnter(object sender, EventArgs e)
{
button.BackgroundImage = <YourNameSpace>.Properties.Resources.<ResourceName>;
}
答案 1 :(得分:0)
如果您使用winforms,请将图片包含在您的资源中:
public Form1()
{
InitializeComponent();
button1.MouseEnter += new EventHandler(button1_MouseEnter);
button1.MouseLeave += new EventHandler(button1_MouseLeave);
}
void button1_MouseLeave(object sender, EventArgs e)
{
this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.img1));
}
void button1_MouseEnter(object sender, EventArgs e)
{
this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.img2));
}