Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. if (dgvAndon.Rows[e.RowIndex].Cells["urgencyOrder"].ToString() == "1")
  2. {
  3. //Here I want to add the image in the image property field DataGridViewImageColumn.
  4. }
  5.  
  6. for (int row = 0; row <= [YourDataGridViewName].Rows.Count - 1; row++)
  7. {
  8. ((DataGridViewImageCell)gvFiles.Rows[row].Cells[1]).Value = Properties.Resources.Picture1
  9. }
  10.  
  11. DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
  12. iconColumn.Name = "AirplaneImage";
  13. iconColumn.HeaderText = "Airplane Image";
  14. dataGridView1.Columns.Insert(5, iconColumn);
  15.  
  16. for (int row = 0; row < dataGridView1.Rows.Count - 1; row++)
  17. {
  18. Bitmap bmp = new Bitmap(Application.StartupPath + "\Data\AirPlaneData\" + dt.Rows[row][4]);
  19. ((DataGridViewImageCell)dataGridView1.Rows[row].Cells[5]).Value = bmp;
  20. }
  21.  
  22. protected void gridView1_RowDataBound(Object sender, GridViewRowEventArgs args)
  23. {
  24. if(args.Row.RowType == DataControlRowType.DataRow)
  25. {
  26. Image img = (Image) e.Row.FindControl("Image1");
  27. img.ImageUrl = setImageURLHere;
  28. }
  29. }
  30.  
  31. OpenFileDialog openFileDialog = new OpenFileDialog();
  32. openFileDialog.RestoreDirectory = true;
  33.  
  34. openFileDialog.Filter = "All picture files (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF";
  35.  
  36. if (openFileDialog.ShowDialog() == DialogResult.OK)
  37. {
  38. FileName = openFileDialog.FileName;
  39. //pictureBox2.Image = Image.FromFile(FileName);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement