The reason is that when initializing the Comboboxcell binding a series of values, but the real assignment is given a value that is not in that range of values, so I reported this error
In the development of the problem will inevitably be due to the problem of data, in order not to let the system collapse, it is necessary to deal with this error message
But how do you catch and handle this anomaly?
I don't know how to capture it, but I know DataGridView already has an event that handles data errors, the Datagridview.dataerror event, which can be handled in this event
Dgvspec.dataerror + =Dgvspec_dataerror;/// <summary> ///handling of data anomalies/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> voidDgvspec_dataerror (Objectsender, Datagridviewdataerroreventargs e) {Loghelper.writelog ("Reagent Dictionaries","Get Data","there is an exception data, check that the import data is complete:"+e.exception.message); Dialogmsghelper.showexcepitonmsg ("Data Exceptions", E.exception,string. Format ("spec. {0} row {1} column data exception, may be due to incomplete import data, please check the data is complete", E.rowindex +1, E.columnindex +1)); E.cancel=true; }
Comboboxcell in DataGridView reported an invalid System.ArgumentException:DagaGridViewComboBoxCell value error