0
I’m dynamically creating columns for a datagrid, but I need to create headers as below, some hint on how to do using c#?
---------------------------------------------
| Person 1 | Person 2 |
| Column 1 | Column 2 | Column 1 | Column 2 |
---------------------------------------------
|Data 1 |Data 2 |Data 3 |Data 4 |
---------------------------------------------
|Data 5 |Data 6 |Data 7 |Data 8 |
---------------------------------------------
I’m using the example below to add columns and rows, but have no idea how to add the multiple header.
public class Item
{
public int Num { get; set; }
public string Start { get; set; }
public string Finich { get; set; }
}
private void generate_columns()
{
DataGridTextColumn c1 = new DataGridTextColumn();
c1.Header = "Num";
c1.Binding = new Binding("Num");
c1.Width = 110;
dataGrid1.Columns.Add(c1);
DataGridTextColumn c2 = new DataGridTextColumn();
c2.Header = "Start";
c2.Width = 110;
c2.Binding = new Binding("Start");
dataGrid1.Columns.Add(c2);
DataGridTextColumn c3 = new DataGridTextColumn();
c3.Header = "Finish";
c3.Width = 110;
c3.Binding = new Binding("Finish");
dataGrid1.Columns.Add(c3);
dataGrid1.Items.Add(new Item() { Num = 1, Start = "2012, 8, 15", Finish= "2012, 9, 15" });
dataGrid1.Items.Add(new Item() { Num = 2, Start = "2012, 12, 15", Finish= "2013, 2, 1" });
dataGrid1.Items.Add(new Item() { Num = 3, Start = "2012, 8, 1", Finish = "2012, 11, 15" });
}
Thank you.