Reputation: 4740
I am trying to change the image in a picturebox when I hover the mouse over it. I am using visual c# 2010 express with windows forms.
Here is the basic code I have at the moment:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void pbMV_MouseHover(object sender, EventArgs e)
{
pbMV.BackgroundImage = My.Resources.mvhov;
tbname.Text = "Hello";
}
private void pbMV_MouseLeave(object sender, EventArgs e)
{
tbname.Text = "";
}
}
}
In the following line it gives me an error in regard to the use of My
.
pbMV.BackgroundImage = My.Resources.mvhov;
The name 'My' does not exist in the current context
SO what am I doing wrong in trying to change the background image of the picture box when I hover my mouse over it?
Sorry if this seems basic too you I have next to no knowledge in c#.] Thanks.
Upvotes: 0
Views: 2488
Reputation: 887215
C# does not have VB.Net's My
keyword.
Instead, you can access the Resources
class directly:
Properties.Resources.SomeResourceName
Upvotes: 3