Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I add items to an already existing combobox cell in a datagridview combobox column ,
Each row contains a different items in the combobox column ,
I want to add the items to the specific combobox cell of a specific row ,
I tried something like this but it didn't work :

dataGridView1.Rows[0].Cells[2].Items.Add();


Please I need help ,

Thank you .
Posted

It should be something like:
C#
DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)myDataGrid.Rows[0].Cells[2];
cbCell.Items.Add(.....);


Documentation for DataGridViewComboBoxCell[^] and its Items[^] property. :)
 
Share this answer
 
v3
Comments
Michael Waguih 20-Jan-11 5:41am    
Thank you it is really what I need .
Nuri Ismail 20-Jan-11 5:49am    
You are welcome. :)
Member 8403770 5-Jun-13 16:54pm    
how can i add a comboboxcell bound to data from database? i don't want a column
Pavan Kumar 10-Sep-14 7:48am    
Thanks, I have resolved my problem too.
use it ---->

DataGridViewComboBoxCell Cmb;
cmb.item.add("Item1");
cmb.item.add("Item2");

GRidView1(CulumnIndex,RowIndex)=cmb
 
Share this answer
 
C#
data = new DataTable();

     da = new MySqlDataAdapter("SELECT * FROM cds", conn);
     cb = new MySqlCommandBuilder(da);

     da.Fill(data);

     DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)dataGridView1.Rows[0].Cells[1];
     foreach (DataRow row in data.Rows)
     {
       int32TextBox1.AutoCompleteCustomSource.Add(row[1].ToString()); //assuming required data is in first column
       cbCell.Items.Add(row[1].ToString());
     }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900