Article View: pl.comp.lang.delphi
Article #80Re: DBGrid i różne kolory
From: Daniel Kowalski
Date: Thu, 18 Sep 1997 12:32
Date: Thu, 18 Sep 1997 12:32
47 lines
2119 bytes
2119 bytes
Jacek Owczarek wrote:
>
> Witam ponownie.
> Mam mały problem, w trakcie wyświetlania rekordów w DBGridzie,
> potrzebuję aby
> wartości np. 'True' były wyświetlane na zielono a 'False' na czerwono.
> Pewnie tzeba użyć zdarzenia OnDrawDataCell, tylko jak?
>
> Pozdrawiam Jacek.
Czesc,
Wlasnie dostalem takiego tipa:
Dynamically update DBGrid row color
Versions: Delphi 2, 3
The DBGrid is a great user interface tool for displaying data. This
technique demonstrates how to dynamically change the color of text in a
DBGrid.
For example, we want our grid to display rows of country information. If
a
country's population is greater than 20 million, we'll display its row
in
blue colored text. We test the values and update the text color in the
OnDrawColumnCell event of the grid.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect:
TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Table1.FieldByName('Population').AsInteger > 20000000 then
DBGrid1.Canvas.Font.Color := clBlue;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
This is a simple but visually profound technique. In addition to just
data
content, you can display the meaning of the information; e.g. a lot of
people, account overdrawn, parts have arrived.
Mam nadzieje, ze to pomoze.
Siemka
--
Daniel Kowalski
mailto: arctus@moskit.art.olsztyn.pl
irc: arctus
Technical Details
Message-ID:
<34211F52.55397F83@moskit.art.olsztyn.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!ict.pwr.wroc.pl!news.icm.edu.pl!news.man.torun.pl!not-for-mailReferences:
<34192EA9.81804F41@polbox.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!ict.pwr.wroc.pl!news.icm.edu.pl!news.man.torun.pl!not-for-mail From: Daniel Kowalski <arctus@moskit.art.olsztyn.pl> Newsgroups: pl.comp.lang.delphi Subject: Re: DBGrid i różne kolory Date: Thu, 18 Sep 1997 14:32:18 +0200 Organization: TORMAN INN site Lines: 52 Message-ID: <34211F52.55397F83@moskit.art.olsztyn.pl> References: <34192EA9.81804F41@polbox.com> NNTP-Posting-Host: ppp-wsch35.olsztyn.tpnet.pl Mime-Version: 1.0 X-Mailer: Mozilla 4.01 [en] (Win95; I) X-Priority: 3 (Normal) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit