Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.ArgumentException: DataGridViewComboBoxCell value is not valid

dataGridView.Rows.Add(
    metaData.Offset.ToString("X2"),
    metaData.Length,
    metaData.Format,        // This parameter goes to a ComboBox cell which throws an
    metaData.Description,   //     exception above                       
    null,
    null);

What is the valid way to programmatically assign data to DataGridViewComboBoxCell?

like image 796
LEMUEL ADANE Avatar asked Nov 28 '22 03:11

LEMUEL ADANE


2 Answers

To Solve this problem, just add “DataError” for DataGridView. That’s all, steps: Double click the datagridview and select the “dataerror” event from the event list.

The DataError event enables you to handle exceptions thrown in code that is called by the control during data processing operations.

thats it :)

like image 151
suresh Avatar answered Dec 05 '22 15:12

suresh


To Solve this problem, add event of "DataError" for DataGridView and then

just write this: e.Cancel = true;

e.g:

private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
    e.Cancel = true;
}        
like image 41
Zolfaghari Avatar answered Dec 05 '22 16:12

Zolfaghari