1.效果图
实现代码:
初始化列代码
/// <summary> /// 初始化时段信息显示列 /// </summary> private void InitColumnTimesInfo() { List<Ctrls.Grid.GridColumn> columns = new List<Ctrls.Grid.GridColumn>(); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"时段", Field = nameof(TimesInfo.VisitingHours), DataType = typeof(string), Visible = true, Width = 40 }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"全选", Field = nameof(TimesInfo.Check), DataType = typeof(bool), Visible = true, Width = 40, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周一", Field = nameof(TimesInfo.Monday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周二", Field = nameof(TimesInfo.Tuesday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周三", Field = nameof(TimesInfo.Wednesday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周四", Field = nameof(TimesInfo.Thursday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周五", Field = nameof(TimesInfo.Friday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周六", Field = nameof(TimesInfo.Saturday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); columns.Add(new Ctrls.Grid.GridColumn() { Caption = $"周日", Field = nameof(TimesInfo.Sunday), DataType = typeof(bool), Visible = true, Width = 100, ReadOnly = false }); dgvTimesInfo.InitColumns(columns); }