在WinForms中绑定到数据源的gridview的布尔列中显示yes / no? [英] Show yes/no in bool column of gridview bound to datasource in Winforms?
本文介绍了在WinForms中绑定到数据源的gridview的布尔列中显示yes / no?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个绑定到数据源(Windows Forms,VB.NET)的gridview。其中一列是boolean类型的属性,我想在列中显示是/否而不是0/1或true / false。这可能吗?你能编辑绑定列的显示吗?
I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One of columns is a property of type boolean, and I want to show "yes/no" in the column instead of 0/1 or "true/false". Is this possible? Can you edit displays of columns that are bound?
推荐答案
我遇到同样的问题,很遗憾我没有找到一个优雅解。
提出了三种解决方法:
I have encountered the same problem, unfortunately I didn't find an elegant solution. Three workarounds are proposed:
- 将另一个属性添加到数据源的类中,该类将返回布尔属性的字符串表示形式。隐藏显示布尔值的列,显示显示字符串值的列。
- 添加一个未绑定的字符串列,使用每行适当的值填充该列,并隐藏布尔绑定列。
- 为您的数据类创建一个包装类,它将显示您希望它们显示在数据网格中的属性。
这篇关于在WinForms中绑定到数据源的gridview的布尔列中显示yes / no?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文