daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Jul 22nd, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top