我现在写一个winform程序
其中数据库中一个表有一个字段是bool类型,有一个是smallInt类型的,
用DataGridView显示的时候,bool类型那一列显示一个CheckBox,而smallInt仅显示普通数字。
现在问题是:
我不想bool那一列显示CheckBox那样子,我想显示成字符串"对"或者"错"
而smallInt则不想显示成十进制格式,要十六进制的
使用水晶报表显示的时候也有类似的问题?
有请高手释疑!!
在线等

解决方案 »

  1.   


    select case bool when 'true' then '对' when 'false' then '错' end from 表名
      

  2.   

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
      if (e.ColumnIndex==2 && e.Value is bool)
      {
      e.Value = (bool)e.Value?"":"";
      }
    }
     
     
      

  3.   


    顶,这个。
    两种方案,一种是  用case 查询语句,类似于下面
    select *,
    publish1= case lower(ltrim(rtrim([Publish]))) 
    when 1 then '通过 ' 
    when 0 then '未通过' 
    else '未知' end 
    from  cn_T_09moty_article 
    where Article_type='video'and Profile_id=4
    ,第二种,就是现实时候,用 三元运算符
      

  4.   

    不好意思,Access数据库能支持这些SQL语句