views:

117

answers:

1

I have a DataGridView and I am populating it through a DataTable. On initializing, I add DataColumns to the DataTable and then set the DataSource of the DataGridView to the DataTable. Here is the code:

DataTable mTable    = new DataTable("Test");

DataColumn  col = new DataColumn;
col.DataType      = System.Type.GetType("System.Boolean");
col.ColumnName  = "First";
col.ReadOnly    = false;
mTable.Columns.Add(col);

col            = new DataColumn;
col.DataType    = System.Type.GetType("System.String");
col.ColumnName  = "Second";
col.ReadOnly    = false;
mTable.Columns.Add(col);

this.myGridView.DataSource = mTable;

This works fine however, I want to make one of the columns showup as a combobox. I think I have to do something with the Column's datatype but I am not sure how to do this. Can anyone give me any pointer towards this?

A: 

change the declaration to this: DataGridViewComboBoxColumn column1 = new DataGridViewComboBoxColumn()

ThanosPapathanasiou
My Columns are DataColumns here, or more specifically System.Data.DataColumn. I believe that I can't add a DataGridViewComboBoxColumn to DataTable
Aamir
is it possible to bypass the whole DataTable and populate the datagrid directly?
ThanosPapathanasiou
Yes, I am trying the same thing right now. But I wanted to know what is the method to do this through DataTable
Aamir