Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
How can I change brush color in DBGrid?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Create small language
by
creaothceann
[
Today
at 09:42:48 am]
Unleashed Pascal (async/a...
by
Fibonacci
[
Today
at 08:11:20 am]
SPAM
by
paweld
[
Today
at 07:17:10 am]
New charts
by
hedgehog
[
Today
at 06:46:20 am]
Automatic generation of *...
by
dbannon
[
Today
at 06:32:16 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How can I change brush color in DBGrid? (Read 4322 times)
Milsa
Sr. Member
Posts: 328
How can I change brush color in DBGrid?
«
on:
May 07, 2016, 05:48:46 pm »
This is my code from Delphi in DBGridDrawColumnCell (it works):
Code: Pascal
[Select]
[+]
[-]
(
Sender as TDBGrid
)
.
Canvas
.
Brush
.
Color
:
=
clGray
;
But in Lazarus doesn't works.
Logged
I work with Lazarus 4.0, FPC 3.2.2, date 2025-05-03
This information is actual to: 3rd Aug 2025
wp
Hero Member
Posts: 13644
Re: How can I change brush color in DBGrid?
«
Reply #1 on:
May 07, 2016, 07:33:10 pm »
The event for changing canvas properties in descendants of TCustomGrid is OnPrepareCanvas:
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
DBGrid1PrepareCanvas
(
sender
:
TObject
;
DataCol
:
Integer
;
Column
:
TColumn
;
AState
:
TGridDrawState
)
;
begin
if
odd
(
TDBGrid
(
Sender
)
.
DataSource
.
Dataset
.
RecNo
)
then
// NOTE: RecNo is not available for all dataset types!
TDBGrid
(
Sender
)
.
Canvas
.
Brush
.
Color
:
=
clSilver
;
if
DataCol
=
0
then
// or: if Column.Index = 0 then
TDBGrid
(
Sender
)
.
Canvas
.
Font
.
Style
:
=
[
fsBold
]
;
end
;
«
Last Edit: May 07, 2016, 07:36:21 pm by wp
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
How can I change brush color in DBGrid?
TinyPortal
© 2005-2018