NeCroFire

NeCroFire

  • NA
  • 86
  • 0

Problem Binding data to DataGridView with ComboboxColoumn & List<>

Oct 1 2010 3:41 AM
Hi

I've been stuck with this since yesterday and I can't find any solution to my problem. I am busy with a WinForms App which has DataGridView on it. I have a List<> object which I want to bind to it.
The DataGrid has 3 normal columns and then it also has a DataGridViewComboBoxColumn.
My List<> object has 3 string fields and then a Arraylist field.
Each ArrayList in the List<> object has different data that corresponds with the rest of the single object within the List<>.

So in other words, I have something like this:
 public class _MyObj
{
public string Field1 {get; set;}
public string Field2 {get; set;}
public string Field3 {get; set;}
public ArrayList Field3 {get; set;}
}

List<_MyObj> obj = <get data from DB>


MyGrid.DataSource = obj;


Now if I bind the List<> to the DataGrid then all the strings will bind fine, but I can't find a way to bind the Arraylist to the ComboBoxColumn. In ASP.NET this is much easier as you can use the RowDataBind event to bind the ArrayList to the Dropdownbox being created for each row. But I can't do it in WinForms. I don't get how something that should be much simpler can so complicated.

Any help would be greatly appreciated.
Thanks

Answers (2)