I've been working most of the day on this, and the solution continues to elude me. My Winform application contains a DataGridView
wherein two of the columns are ComboBox
dropdown lists. Oddly, the DataGridView
appears to populate correctly, but it throws up a plethora of errors while populating or whenever there is a mouseover or seemingly any other triggerable event related to the DataGridVeiw
. Specifically, I am getting two repeating errors for System.ArgumentException
and System.FormatException
. The message text for both of these errors is:
"DataGridViewComboBoxCell value is not valid. To replace this default dialog please handle the DataError event."
I don't want to merely mask this problem by handling the DataError
event. I want to resolve the issue that is causing error. This is how I am populating the list:
class ManageProcsRecord
{
public SectionType PageSection { get; set; }
public Int32 ContentID { get; set; }
public String Content { get; set; }
public Int32 SummaryID { get; set; }
public RoleType UserRole { get; set; }
public String Author { get; set; }
public String SysTime { get; set; }
}
public enum SectionType
{
ESJP_SECTION_HEADER = 1,
ESJP_SECTION_FOOTER,
ESJP_SECTION_BODY
}
public enum RoleType
{
ESJP_ROLE_NONE = 1,
ESJP_ROLE_TEST_ENG,
ESJP_ROLE_FEATURE_LEAD,
ESJP_ROLE_TEAM_LEAD
}
List<ManageProcsRecord> records =
this.dbif.GetProcedure(this.procList.ElementAt(selectedIndex).PrimaryKey);
foreach (ManageProcsRecord record in records)
{
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(this.dataGridView1);
row.Cells[0].ValueType = typeof(SectionType);
row.Cells[0].Value = record.PageSection;
row.Cells[1].Value = record.Content;
row.Cells[2].Value = (record.SummaryID != -1);
row.Cells[3].ValueType = typeof(RoleType);
row.Cells[3].Value = record.UserRole;
row.Cells[4].Value = record.Author;
row.Cells[5].Value = record.SysTime;
this.dataGridView1.Rows.Add(row); // error fest starts here
}
Any thoughts or suggestions on how to resolve this are much appreciatd!