I want to, while avoiding databinding, to set the selected index in a ComboBox in a DataGridView. It is not connected to a DB.
All solutions I have found have the Da
Since the DataGridViewComboBoxColumn has no SelectedIndex or SelectedValue properties, you can try and set the value like this example:
DataGridViewComboBoxColumn cmbCurrencies = (DataGridViewComboBoxColumn)myDataGridView.Columns["ComboboxCurrencyColumn"];
var currencies = entities.currencies.Select(c => c.currencyName).DefaultIfEmpty().ToList();
cmbCurrencies.DataSource = currencies;
and then:
for (int i = 0; i <= myDataGridView.RowCount - 1; i++)
{
myDataGridView.Rows[i].Cells["Index of Combobox Column"].Value = "Pound";
}
See also if this may help.