Hi
I have a image called check.jpeg in the resource folder. I have a datagridview which shows some values. Now when I right-click on the dgv I have a option called Checked-in upon clicking on this I want that image check.jpeg to be displyed on that rows third cell. How to do this
Thanks
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Sep 17, 2009, 3:48 AM EDT
Here is What you want . If you don't Under stood the Code I also Included Project Files take a look at them Link is at bottom of the post :)
dont forget to mark "Do you like answer" please it will give me some credits :)
private void checkToolStripMenuItem_Click(object sender, EventArgs e)
{
dataGridView1.CurrentRow.Cells[0].Value = Properties.Resources.check;
}
private void uncheckToolStripMenuItem_Click(object sender, EventArgs e)
{
dataGridView1.CurrentRow.Cells[0].Value = null;
}
Download Project Files
Kirtan PatelRank #292 · 8.6K reputationPosted Sep 18, 2009, 6:13 AM EDT
You can Programatically add Image Column By Following Code
DataGridViewColumn Imagecolumn = new DataGridViewColumn(new DataGridViewImageCell());
Imagecolumn.DisplayIndex = 1;
Imagecolumn.HeaderText = "Image Column";
dataGridView1.Columns.Add(Imagecolumn);
and You Dont have to Set any Path to Image
Here you can see i Have Check.png Image Named "Check"
So, I just Have to
Write Code Like Below no need to set any path
private void checkToolStripMenuItem_Click(object sender, EventArgs e)
{
dataGridView1.CurrentRow.Cells[1].Value = Properties.Resources.check;
}
Roei BarRank #1,271 · 1.4K reputationPosted Sep 17, 2009, 3:35 AM EDT
have a look @ this post, i belive this is what you are looking for
http://www.codeproject.com/KB/database/DataGridEdtAlmostAnythin.aspx?df=100&forumid=157727&exp=0&select=1058499
sachi vasishta180 reputationPosted Sep 17, 2009, 3:43 AM EDT
private void checkedToolStripMenuItem_Click(object sender, EventArgs e)
{
DataGridViewRow row = dataGridView1.CurrentRow;
int index1 = row.Index;
dataGridView1.Rows[index1].Cells[2].value=?????? // what I have to write here in order to display that image(picturebox1)
}
this is my problem
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Sep 17, 2009, 4:14 AM EDT
i think you want to show some image on specified datagrid cell. right......
simple you can try if your datagridcell is taken by you as image type :
dataGridView1.Rows[index1].Cells[2].value= System.Drawing.Image.FromFile(ImagePath);
sachi vasishta180 reputationPosted Sep 18, 2009, 5:59 AM EDT
I want to know how to have a datagridview's 2nd column as image type (I know I can do it in the properties of dgv but I want to do it by coding) And I have the images in the resource folder of the project. So what path(ImagePath) I have to give in this System.Drawing.Image.FromFile(ImagePath);
Thanks
bhavana kamble2 reputationPosted Nov 11, 2010, 8:37 PM EST
plz
thanking u;
Abdou Abdelkbir5 reputationPosted Aug 27, 2015, 8:11 AM EDT
Abdou Abdelkbir5 reputationPosted Aug 27, 2015, 8:11 AM EDT