title: Populating a DataGridViewComboBox column from an ENUM and setting it - System.FormatException thrown
body: <p>I guess I'm the latest to encounter this issue. I have tried several different approaches (based on other posts in this forum to creating a Yes/No DataGridViewComboBox column and populating its data source using an ENUM, and populating/setting it accordingly. I have been able to get the combo box on each row of the DataGridView to set properly according to the corresponding data.</p>
  <p>Here is the ENUM I am using:</p>
  <p><a href="https://i.stack.imgur.com/5y97v.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5y97v.jpg" alt="enter image description here" /></a></p>
  <p>Here is the code I am using to populate it:</p>
  <p><a href="https://i.stack.imgur.com/0H783.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0H783.jpg" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/KS8b7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KS8b7.jpg" alt="enter image description here" /></a></p>
  <pre><code>                            //
                              DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
                              //DataGridViewTextBoxColumn cmb = new DataGridViewTextBoxColumn();
  
                              cmb.DataPropertyName = &quot;approved&quot;;
                              cmb.HeaderText = Get_Header_Text_For(cmb.DataPropertyName);
                              cmb.HeaderCell.Style.BackColor = Color.Green;
                              cmb.HeaderCell.Style.ForeColor = Color.White;
                              cmb.DefaultCellStyle = CStyleCenter;
                              cmb.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                              cmb.Name = approvedCheckCol;
                              cmb.DataSource = new List&lt;AccessNCPCBase.YesNo&gt;((AccessNCPCBase.YesNo[])Enum.GetValues(typeof(AccessNCPCBase.YesNo)))
                                                    .Select(value =&gt; new { Display = value.ToString(), Value = (int)value })
                                                    .ToList();
                              cmb.ValueMember = &quot;Value&quot;;
                              cmb.DisplayMember = &quot;Display&quot;;
                              cmb.Visible = true;
                              cmb.ReadOnly = false;
                              //
                              dgvParm.Columns.Add(cmb);
                              dgvParm.Columns[approvedCheckCol].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
  </code></pre>
  <p>Here is a screenshot of the populated (from the ENUM) data source for the new DataGridViewComboBoxColumn:</p>
  <p><a href="https://i.stack.imgur.com/iYU8o.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iYU8o.jpg" alt="enter image description here" /></a></p>
  <p>When I test the code, the following exception is thrown in the DataGridView's DataError event:</p>
  <p><a href="https://i.stack.imgur.com/oIZye.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIZye.jpg" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/fLvYr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fLvYr.jpg" alt="enter image description here" /></a></p>
  <p>And here is the result:</p>
  <p><a href="https://i.stack.imgur.com/yL0MD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yL0MD.jpg" alt="enter image description here" /></a></p>
  <p>Again, I have tried several of the approaches suggested in this thread. I even changed the code to add the DataGridViewComboBoxColumn before populating the DataGridView; My code was originally adding the column after populating the DataGridView, but an earlier poster mentioned that fixed their problem so I tried it, but no success.</p>
  <p>Does anyone have any ideas on what I am doing wrong or what I am missing? Any suggestions and/or insights would, of course, be greatly appreciated.</p>
  <p>Chris Fleetwood blkwebman@mindspring.com</p>