给DataGrid列头绑定时间

WPF

public void DataGridBinDingTime()
{
List<string> times = new List<string>();
string time = _startTime.SelectedValue.ToString();

string[] arr = time.Split(':');
string splittime = arr[0];
for (int i = Convert.ToInt32(splittime); i <= 24; i++)
{
times.Add(i.ToString() + ":00");
}
for (int i = 0; i < times.Count; i++)
{
DataGridTextColumn dl = new DataGridTextColumn();
dl.Header = times[i];
_gridGroup.Columns.Add(dl);
}
}

_gridGroup:是DataGrid的Name

上一篇:如何在后台获取DataGrid中的一个CheckBox


下一篇:WPF DataGrid数据绑定