Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. private void showData(List<Item> collection)
  2. {
  3. gwQuestions.AutoGenerateColumns = false;
  4. gwQuestions.DataSource = addNotSet(collection);
  5.  
  6. foreach (DataGridViewRow row in gwQuestions.Rows)
  7. {
  8. DataGridViewImageCell cell = row.Cells[2] as DataGridViewImageCell;
  9. cell.ValueType = typeof(System.Drawing.Image);
  10. if (collection[row.Index].Result)
  11. {
  12. cell.Value = (System.Drawing.Image)Properties.Resources.Check;
  13. }
  14. else
  15. {
  16. cell.Value = (System.Drawing.Image)Properties.Resources.Cancel;
  17. }
  18. }
  19. }
  20.  
  21. dataGridView1.CellFormatting += dataGridView1_CellFormatting;
  22.  
  23. void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  24. {
  25. if (dataGridView1.Columns[e.ColumnIndex].Name == "ImageColumnName")
  26. {
  27. if (collection[e.RowIndex].Result)
  28. {
  29. e.Value = (System.Drawing.Image)Properties.Resources.Check;
  30. }
  31. else
  32. {
  33. e.Value = (System.Drawing.Image)Properties.Resources.Cancel;
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment