M
miss2046
Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位大侠,如何在数据表格(dbgrid 或者 dbgrideh)中实现真正的斑马线效果?
类似下面的这种代码只要表格进入修改或新增一行时,表格就会变成同一种颜色而失去所谓的斑马线效果:
//画斑马线
begin
with TDBGridEh(Sender) do
begin
if not Assigned(DataSource) or
not DataSource.DataSet.Active then exit;
if gdSelected in State then
begin
Canvas.Brush.Color := clNavy;
Canvas.Font.Color := clWhite;
end else
if DataSource.DataSet.RecNo mod 2=0 then
Canvas.Brush.Color:= clInfoBk;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
类似下面的这种代码只要表格进入修改或新增一行时,表格就会变成同一种颜色而失去所谓的斑马线效果:
//画斑马线
begin
with TDBGridEh(Sender) do
begin
if not Assigned(DataSource) or
not DataSource.DataSet.Active then exit;
if gdSelected in State then
begin
Canvas.Brush.Color := clNavy;
Canvas.Font.Color := clWhite;
end else
if DataSource.DataSet.RecNo mod 2=0 then
Canvas.Brush.Color:= clInfoBk;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;