Click here to Skip to main content
11,578,524 members (60,818 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# DataGrid
Hi


I have datagridview. I was change datacolum type to DataGridViewComboBoxColumn;

but when I binding datasource to my datagrid have this error :the following exception occurred in the datagridview .
system.ArgumentException:DataGridViewComboBoxCell value is not valid

to replace this defult dialog please handle the dataerror event;


Can you Help me?
Posted 18-Oct-11 23:16pm
Edited 18-Oct-11 23:17pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

When you create a column of combo boxes, those combos must be assigned a list of items which will be displayed when you select it. The value which goes into the dgv cell must be in that list of items. In your case, one or more of the combo box cells contains a value which is not in the item list, hence the cell value is invalid.
  Permalink  
Comments
raheleh_es at 22-Oct-11 0:26am
   
how Can I add combo box cell for all row when I set dataset to data grid view ;

...I wrote this code but it does n't work:datagridview.DataSource = ds;

datagridview.DataMember = "selectE";

DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();

for (int i = 0; i < ds.Tables["Post"].Rows.Count; i++)

{

cell.Items.Add(ds.Tables["Post"].Rows[i][0].ToString());

}

for (int j = 0; j < ds.Tables["selectE"].Rows.Count; j++)

{ datagrid_Name181[0,j] = cell;

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Peter Leow 135
1 OriginalGriff 113
2 Richard MacCutchan 85
3 Frankie-C 75
4 Afzaal Ahmad Zeeshan 75
0 OriginalGriff 904
1 Sergey Alexandrovich Kryukov 715
2 Abhinav S 573
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 393


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 19 Oct 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100