When I created new project I went to Solution Explorer and in Properties I double clicked on Resources.resx. Here I clicked on Add Resource and Add Existing File. Selected images been added and I can use them for darg&drop on form.
My problem is I need to create sort of rollover effect on pictureBox. PictureBox image property is set to none for start. When I go with mouse over pictureBox I want to upload image from resources. How do I do it?

pictureBox.Image = ? ? ? ? ?

PS: Any good place with C# tutorials?

OK no error after that, but once I get mouse over pictureBox image is not uploaded. Did I forgot somethink like Paint? I wish they library system was more like Java API...

In pictureBox event handler (MouseOver) assign the picturebox.image to the image which in resources. It works!

commented: Thank you for help +7

You have to be a little slow when moving your mouse over the picturebox. If you want precision movement try considering writing code in the MouseEnter, MouseLeave event handlers.

Thanks,
Peter Pollen <advertising url snipped>

I forgot to attach silly event handler :$

For anybody who wish to generate 2D array of pictureBoxes on runtime here is code snipped for it

for (int x = 0; x < stonePlaced.GetUpperBound(0); x++)
{
	for (int y = 0; y < stonePlaced.GetUpperBound(1); y++)
		{
			stonePlaced[x, y] = new PictureBox();
			stonePlaced[x, y].Size = new Size(80, 80);
			stonePlaced[x, y].Location = new Point((80 * x),(80 * y));
			stonePlaced[x, y].BackColor = 
                                   System.Drawing.Color.Transparent;
			stonePlaced[x, y].MouseHover += 
                                   new System.EventHandler(this.stonePlaced_MouseHover);
			stonePlaced[x, y].MouseLeave += 
                                  new System.EventHandler(this.stonePlaced_MouseLeave);
			boardPanel.Controls.Add(stonePlaced[x, y]);
		}
}

And event listeners

private void stonePlaced_MouseHover(object sender, EventArgs e)
{
	PictureBox pb;
	pb = (PictureBox)sender;
        pb.Image = Properties.Resources.purple;
}

private void stonePlaced_MouseLeave(object sender, EventArgs e)
{
	PictureBox pb;
	pb = (PictureBox)sender;
	pb.Image = null;
}

When I created new project I went to Solution Explorer and in Properties I double clicked on Resources.resx. Here I clicked on Add Resource and Add Existing File. Selected images been added and I can use them for darg&drop on form.
My problem is I need to create sort of rollover effect on pictureBox. PictureBox image property is set to none for start. When I go with mouse over pictureBox I want to upload image from resources. How do I do it?

pictureBox.Image = RiskIT.Properties.Resources._1

PS: Any good place with C# tutorials?

pictureBox.Image = RiskIT.Properties.Resources._1
pictureBox.Image = RiskIT.Properties.Resources._1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.