c# - WinForms dev express bind true/false column with a checkbox
问题描述
I'm working on a Windows Forms project and I have some data in a XtraGrid.GridControl
with these columns:
ID
, Description
, To Process
I'm loading these data from database, and the column To Process
contains a boolean
field.
I would like to have instead of the current 1
and 0
values a checkbox, that will be checked if the value is 1
and unchecked if the value is 0
.
How can I achieve this with Dev Express 16
?
This is what I did so far:
- imported a
DevExpress.XtraGrid.GridControl
in my formDesign
; - added three columns
ID
,Description
andTo Process
; populated the
GridControl
DataSource
from code behind with this method:private void LoadTableData() { // initialization gcTable.DataSource = null; string query = " SELECT id, description, to_process FROM test_table "; DataTable dt = Utils.ExecuteQuery(query); if (dt != null && dt.Rows.Count > 0) { gcTable.DataSource = dt; } }
As now, I have my table populated but with 1
and 0
values in the column To Process
.
解决方案
Assign a RepositoryItemCheckEdit to your To Process
column's ColumnEdit property and set its ValueChecked and ValueUnchecked properties if necessary. More information here.
推荐阅读
- python - 如何在不丢失数据的情况下迭代 heapq?
- linux - 没有建立连接时 TCP 服务器接受()连接
- typescript - 如何在打字稿中使用条纹类型
- c# - C# BinaryWriter/BinaryReader - 阅读器顺序与写入顺序不匹配
- azure - Azure Function 2.0 使用应用程序设置 json
- ios - 如何在 SwiftUI 中淡化 SF 符号的顶部或底部边缘?
- python - 我正在寻找一个类似于“str.isupper()”但带有符号的函数?
- python - 为什么看和说序列的这两种实现有不同的执行时间?
- markdown - 在 bookdown 和 markdown 中转义 HTML 仍然很困扰
- javascript - React Apollo Client useQuery Hook gql Uncaught TypeError:(...) is not a function