trouble adding a databound combobox to a datagrid

I have a datagrid that has columns like "tasks", "date completed" and "rating". I am retrieving data and binding the grid like this:

<code>
DataSet dsProgramTasks = data.GetStandardProgramTasks(); // ADO.Net access method
</code>

I would like the "rating" column to be databound a combo-box. I have an access method for this as well:

<code>
DataSet dsratings = data.GetRatingss(); // ADO.Net access method
</code>

Now, how do I add a combo box to the datagrid? I know that I have to alter the datagrid tablestyle somehow but I'm at a loss exactly what to do....I think I have to do something like this (but I can't get it to work!)

<code>
DataGridTableStyle myGridStyle = new DataGridTableStyle();
myGridStyle.MappingName = "Tasks";

DataGridTextBoxColumn nameColumnStyle = new DataGridTextBoxColumn();
nameColumnStyle.MappingName = "Rating";
nameColumnStyle.HeaderText = "Rating";
myGridStyle.GridColumnStyles.Add(nameColumnStyle);

dgProgramTasks.TableStyles.Add(myGridStyle);
</code>

[1096 byte] By [Dexter] at [2007-12-16]
# 1
There is no built in solution in the v1.1 data grid. Basically you will need to code up your own data bound combobox column. While there are some samples of plain data grid combobox columns, none of them are *data bound* combobox columns.

In addition to just hooking up the ComboBox::DataSource/DisplayMember properties, you would need to:
1. keep track of the currently selected item in the data bound combobox column. You would have to do this on a “per row” basis.
2. correctly paint the currently selected item
3. correctly implement editing the combobox column
4. correctly implement pushing back the value to the back end from the combobox column.

The new DataGridView control in Visual Studio 2005 enables this scenario out of the box

-mark
DataGridView Program Manager
Microsoft
This post is provided "as-is"

MarkRideout at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...