WinForms dev express bind true/false 带有复选框的列

WinForms dev express bind true/false column with a checkbox

我正在处理一个 Windows Forms 项目,我在 XtraGrid.GridControl 中有一些数据,其中包含以下列:

IDDescriptionTo Process

我正在从数据库加载这些数据,To Process 列包含一个 boolean 字段。

我想要一个复选框来代替当前的 10 值,如果值为 1 则选中该复选框,如果值为 [=] 则取消选中19=].

如何使用 Dev Express 16 实现此目的?


这是我目前所做的:

像现在一样,我填充了 table,但在 To Process.

列中有 10

分配一个 RepositoryItemCheckEdit to your To Process column's ColumnEdit property and set its ValueChecked and ValueUnchecked properties if necessary. More information here.

您可以使用 gridView1_CustomRowCellEdit 事件更改网格视图单元格的存储库。如果数据列是布尔类型,则网格控件的单元格将是复选框。

dt.Columns["to_process"].DataType = typeof(bool);

这是 CustomRowCellEdit 事件的示例代码。

    void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
    {
        if (e.Column.FieldName == "to_process")
        {
            DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repChk = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
            e.RepositoryItem = repChk;
        }
    }