有一个状态字段,在数据库里用的是数字,0,1,2表示,可是在dbgrid里显示的时候要显示成中文
怎么办啊?

解决方案 »

  1.   

    假设你的字段名叫MZ,类型为Integer,我来举一个例子。
    把一切工作做好后,在DBGrid1的OnDrawDataCell事件中写下如下代码:If (Field.FieldName='MZ') And (Field.AsInteger=1) then
       DBGrid1.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,'男');
    If (Field.FieldName='MZ') And (Field.AsInteger=2) then
       DBGrid1.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,'女');
      

  2.   

    请问是字段名显示成中文呢,还是数字(0,1,2)用中文显示?
    如果是前者,清告诉我你是用ado来做的吗?[email protected]
      

  3.   

    selece case when ziduan=0 then '零' ziduan=1 then '一' else '二' end as ziduan from table.....看SQL的帮助