Check the last method in your example:
private void Form1_Load(object sender, EventArgs e)
{
CalendarColumn col = new CalendarColumn();
this.dataGridView1.Columns.Add(col);
this.dataGridView1.RowCount = 5;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
row.Cells[0].Value = DateTime.Now;
}
}
This is where the columns are added to the DataGridView
. You can use the same way to add any column object derived from DataGridViewColumn
to your grid.
[Edit]
Before binding, set the DataGridView.AutoGenerateColumns
property to false
and add your custom columns.
You will also have to set the DataPropertyName
property for each column, to define which property will be bound to which column:
CalendarColumn col = new CalendarColumn();
col.DataPropertyName = "Date"; // if your class has a "Date" property
this.dataGridView1.Columns.Add(col);