Reputation: 408
So here's what I have: A DataGridView
with a ComboBox
cell, which is DataBound
to an ArrayList
of items. The ComboBox
is populated properly. What I want is to set the ComboBox
to one of its items after it has been populated. Is there any way to do this ? Here is the ComboBox
population method:
public void PopulateAssignToComboBox(ArrayList members)
{
_editForm.cb_editAssignTo.Items.Clear();
var source = new BindingSource();
source.DataSource = members;
col_assignedToTemplate.DataSource = source;
}
Upvotes: 1
Views: 438
Reputation: 11514
Set that property on the grid's data to the value you want and the grid will sync with it. Don't manipulate UI elements programmatically, manipulate the bound data. The combobox doesn't exist unless the cell is selected anyway - it is overlayed when the cell is active. You can access the combobox in the EditingControlShowing event, but as I said, this is a poor approach to achieve your goal.members
Upvotes: 1