【问题标题】:Infragistics WinGrid: How to make a CheckBox column initially checkedInfragistics WinGrid:如何使 CheckBox 列最初被选中
【发布时间】:2011-07-27 07:44:15
【问题描述】:
我有一个带有未绑定列的 Infragistics WinGrid(UltraGrid、UltraWinGrid 等...)。它有Style = Checkbox 和DataType = System.Boolean。我已将DefaultCellValue 设置为true,但每个新行都以cell.Value == False 出现在该列中。我怎样才能让默认值起作用?谢谢!
【问题讨论】:
标签:
c#
checkbox
infragistics
ultrawingrid
wingrid
【解决方案1】:
如果一切都失败了,我建议您恢复手动设置 InitializeRow 事件的值。
【解决方案2】:
尝试使用yourColumn.DataType = typeof(bool) 和yourColumn.DefaultCellValue = true。
【解决方案3】:
我看到这是一篇旧帖子,但这可能有助于有人在谷歌上搜索答案!
在新行上,您可以使用 InitializeTemplateAddRow 事件,从那里您可以设置所需列的值
//Add TemplateAddRow handler
_ultraGrid.InitializeTemplateAddRow += _ultraGrid_InitializeTemplateAddRow
//In the InitializeTemplateAddRow set the cells value
e.TemplateAddRow.Cells[CELLNAME].Value = true;
//OR
e.TemplateAddRow.Cells[index].Value = true;
【解决方案4】:
如果可能的话,我喜欢在绑定到网格时使用我自己的视图模型类,所以当我遇到这个问题时,我只需添加所需的列,默认值为 true。
如果您不能使用自己的视图模型类,您也可以处理网格的 Initialize 事件并将其设置在那里。