开发者

Show yes/no in bool column of gridview bound to datasource in Winforms?

开发者 https://www.devze.com 2022-12-22 19:42 出处:网络
I have a gridview that is bound to a datasource (Windo开发者_如何学Cws 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 \"tru

I have a gridview that is bound to a datasource (Windo开发者_如何学Cws 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:

  1. Add another property to the data source's class, which returns your string representation of the boolean property. Hide the column showing the boolean value, display the column showing the string value.
  2. Add an unbound string column, populate that column with the appropriate value for each row, and hide the boolean bound column.
  3. Create a wrapper class for your data class, which exposes the properties as you'd like them to be shown in the datagrid.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号