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");
comboBox.SelectedIndex = x;
comboBox.SelectedIndex = x;

this is not valid for datagridview combo boxes

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.