Not much detail to work with. Are you using data binding? If so, what sort of object are you binding to? I was doing something similar recently that involved binding to a custom list of custom key/value pair objects that you might find helpful. The combobox simply displays the first item in the list as a default value. The key/value pair objects expose two public properties named (amazingly) Key and Value. After binding the DataGridViewComboBoxColumn to a BindingSource object you can do this:
Code:
private void DisplayFirstItemInComboColumn()
{
DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn)
LineItemsDataGridView.Columns["Product"];
for (int x = 0; x <= LineItemsDataGridView.Rows.Count - 1; x++)
{
DataGridViewCell cell = LineItemsDataGridView.Rows[x].Cells["Product"];
if (column.Items.Count > 0)
{
cell.Value = (KeyValuePair)column.Items[0];
}
}
}
The DataGridViewComboBoxColumn is configured like this:
Code:
this.Products.DataSource = this.ProductListBindingSource;
this.Products.DisplayMember = "Value";
this.Products.HeaderText = "Product";
this.Products.Name = "Product";
this.Products.ValueMember = "Key";
Anyway, you're basically just getting a reference to a DataGridViewCell object, then setting its Value property.
HTH,
Bob