[英]c# windows form datagridview cell display text
I bind the datagrid from the data i get from the database using code as below 我使用下面的代码将我从数据库获得的数据绑定到数据网格
dgvName.Datasource = ds.Table[0]; dgvName.Datasource = ds.Table [0];
The data as below 数据如下
Id Name Active
1 Test 1
2 Test1 0
3 Test3 0
I wish to display the active as "Y" or "No" instead of 1 or 0. I try CellFormatting handler but it's not work. 我希望将活动显示为“ Y”或“ No”,而不是1或0。我尝试使用CellFormatting处理程序,但是它不起作用。 Active datatype is int.
活动数据类型为int。 How I can do that?
我该怎么做? Please help.
请帮忙。
The simplest you could think is: Add a new property on your class, for example 您可能想到的最简单的方法是:例如,在类上添加新属性
public string ActiveText
{
get { return _active ? "Y" : "N"; }
}
and bind it to column you want 并将其绑定到您想要的列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.