I need a way in which I can define the column type at run-time.
Here is my code:
foreach (DataGridViewColumn column in this.dataGrid.Columns)
{
???
/
You can't change the type of a DataGridView column after it is created but there is nothing to stop you creating columns as needed at run-time.
So, depending on the logic the determines the type of each column, you create columns as needed and add them to the DataGridView.
An example of creating a checkbox column is below:
DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn()
dataGridView1.Columns.Add(col);
Without any more information on what determines your column types it is hard to give more advice, but you could easily use this technique with a DataTable, inspecting the type of each of its columns, or even using reflection over an object you are binding the datagridview to.