Comboboxcell in DataGridView reported an invalid System.ArgumentException:DagaGridViewComboBoxCell value error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.