Ok try this
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;
using System.Data;
namespace SAMPLE
{
public partial class FrmProfile : Form
{
public FrmProfile()
{
InitializeComponent();
}
private void FrmProfile_Load(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 4;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
dataGridView1.Columns[3].Name = "Image Path";
string[] row = new string[] { "1", "Product 1", "1000", Application.StartupPath + "\\Image Path\\Chrysanthemum.jpg" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000", Application.StartupPath + "\\Image Path\\Chrysanthemum.jpg" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000", Application.StartupPath + "\\Image Path\\Chrysanthemum.jpg" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000", Application.StartupPath + "\\Image Path\\Chrysanthemum.jpg" };
dataGridView1.Rows.Add(row);
DataGridViewImageColumn img = new DataGridViewImageColumn();
Image image = Image.FromFile(Application.StartupPath + "\\Image Path\\Chrysanthemum.jpg");
img.Image = image;
dataGridView1.Columns.Add(img);
img.HeaderText = "Image";
img.Name = "Chrysanthemum";
dataGridView1.Columns[3].Visible = false;
}
private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
panel1.Visible = false;
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int currentRowIndex, currentColumnIndex;
currentRowIndex = dataGridView1.CurrentCell.RowIndex;
currentColumnIndex = dataGridView1.CurrentCell.ColumnIndex;
if (currentColumnIndex == 4)
{
string path = dataGridView1[3, currentRowIndex].Value.ToString();
Image image = Image.FromFile(path);
if (image != null)
{
pictureBox1.BackgroundImage = image;
panel1.Visible = true;
}
}
else
{
panel1.Visible = false;
}
}
}
}
the codes that i have provided will not work on Mouse Hower event but it will work on CellClick event of the datagridview.
More over you will need to add one more column as Image path to bring the image path in that column but don't worry it will be set to visible false like i have done above.