⌘BABAKOV.NET Let's code!
100% [light] [ru]

Creating Programmatically DataGridViewComboBoxCell in C#

In this post, I will provide an example of how to programmatically add DataGridViewComboBoxCell.
How to programmatically fill DataGridView was considered here.

The operation of converting the selected DataGridView cell is performed with an existing cell, so we need to create this cell using the previous article, in our case, we will change cells in column 1 and row 1.

This method works 100% with text fields. You can also not convert and set it immediately. But I am assuming that not all cells need to be ComboBoxes and therefore such a need may arise.

DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)dataGridView1.Rows[1].Cells[1];



We have selected a cell from our datagrid and made it a ComboBox.
Now we are filling…

comboCell.Items.Add("1 - Первый");
comboCell.Items.Add("2 - Второй");
comboCell.Items.Add("3 - Третий");
comboCell.Items.Add("4 - Четвёртый");



That's it.

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.