DBgrid,DataSource1 显示问题(50)

S

shhw

Unregistered / Unconfirmed
GUEST, unregistred user!
在数据库中有一个表,其中一个字段是Real型的。当里面有数据:-1,-2 时显示为-1 对应‘****’,-2对应‘###’,其余的数据正常显示
 
procedure Tfm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin with TDBGrid(Sender) do begin if dbgrid1.DataSource.DataSet.FieldByName('字段名').AsString='-1' then Canvas.TextOut(Rect.Left+4,Rect.Top+2,'****') else if dbgrid1.DataSource.DataSet.FieldByName('字段名').AsString='-2' then Canvas.TextOut(Rect.Left+4,Rect.Top+2,'###') end;end;
 
字型 Event: OnGetText(Sender: TField; Text: String; DisplayText: Boolean);if TField(Sender).AsString = '-1' then Text := '****';if TField(Sender).Asstring = '-2' then Text := '###';
 
没有人会?
 
上面的达不到要求?
 
多人接受答案了。
 
顶部