其他分享
首页 > 其他分享> > 给DataGrid列头绑定时间

给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

标签:dl,string,int,绑定,arr,times,DataGrid,列头
来源: https://www.cnblogs.com/AnYiJianMo/p/14850763.html