0

Hi there,
I have a question regarding datagridview in C#, when a form loads I have given the command to add a new row to the datagrid view , and in that datagridview there is a combobox and has items In it.when the form loads I want one item in the datagrid view combo box to be displayed as default. How can I do this??

dgvActions.Rows.Add();
            DataGridViewComboBoxColumn comboBox = (DataGridViewComboBoxColumn)dgvActions.Rows[0].Cells[2].OwningColumn;
            //comboBox.Items.Clear();
            comboBox.Items.Add("External Kick Off");
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by nick.crane
0

Another way to set the value of a combo it to set its Text property.
For the DGV combo the Text property is the cell Value.
So you need to make sure the new row has the value you want to see in the combo column field.
This might work: dgvActions[0, 2].Value = "External Kick Off"; You might still need to add the value to the combo columns list.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.