【问题标题】: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 事件并将其设置在那里。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-25
        相关资源
        最近更新 更多