antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
V¡®u§

dbGrid zebrado (Delphi)

1 post in this topic

Quando utilizamos dbGrid e este recebe muitos registros fica dificil ler toda a linha, principalmente se possuimos um grande número de colunas, um recurso que podemos lançar mão para ao menos amenizar essa situação é o efeito "zebrado", onde temos linhas com cores diferentes, na verdade duas cores diferentes que se intercalam. Então vamos ao exemplo, no evento OnDrawColumnCell:

if odd(ClientDataSet4.RecNo) then

DBGrid1.Canvas.Brush.Color:= clmenubar

else

DBGrid1.Canvas.Brush.Color:= clCream;

TDbGrid(Sender).Canvas.font.Color:= clBlack;

if gdSelected in State then

with (Sender as TDBGrid).Canvas do

begin

Brush.Color := clmoneygreen;

FillRect(Rect);

Font.Style := [fsbold]

end;

TDbGrid(Sender).DefaultDrawDataCell(Rect, TDbGrid(Sender).columns[datacol].field, State);

Share this post


Link to post
Share on other sites
antiblock
Rodnia | Alpha & Omega

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this