标签归档:DBGridEh

EhLib中DBGridEh单元格根据不同内容显示不同颜色的方法

在单元格中显示不同颜色,有两种情形,一是对整个表格起作用,另一个是对某一列起作用。

一、作用范围在整张表中,在DBGridEh的OnGetCellParams事件中写如下代码:

procedure TfrmMain.DBGridEh3GetCellParams(Sender: TObject; Column: TColumnEh;
  AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
  if Column.Field.AsString='优良' then
    Background := clRed;
end;
…
发表在 随记 | 标签为 , | 一条评论

EhLib中DBGridEh单元格内容为0不显示的方法

若想在DBGridEh的某列中隐藏为0的数据,在该列的OnGetCellParams事件中进行判断处理。

procedure TfrmMain.DBGridEh3Columns7GetCellParams(Sender: TObject;
  EditMode: Boolean; Params: TColCellParamsEh);
begin
  if Params.Text='0.00' then
    Params.Text:='';
end;
…
发表在 随记 | 标签为 , | 留下评论