Could you please be more specific?
If you're referring to how to add columns to a DataGridView where you don't know what the columns would be, it would look something like this;
private void Form1_Load(object sender, EventArgs e)
{
try
{
DataGridViewColumn column;
DataGridViewCell cell = new DataGridViewTextBoxCell();
for (int i = 0; i < 5; i++)
{
column = new DataGridViewColumn();
column.Name = "column" + (i+1).ToString();
column.HeaderText = "Column " + (i+1).ToString();
column.ValueType = typeof(string);
column.CellTemplate = cell;
dataGridView1.Columns.Add(column);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
NOTE: If you're going to be adding columns dynamically, make sure the column doesn't already exist before trying to add it.