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
ThorVG - test (lightweigh...
by
LeP
[
Today
at 03:07:25 pm]
AdvancedHTTPServer: A Go-...
by
LeP
[
Today
at 03:01:15 pm]
Frustrating Error When us...
by
TYDQ
[
Today
at 01:43:32 pm]
Questions from a Windows ...
by
anse
[
Today
at 01:18:40 pm]
We are starting to use La...
by
ALLIGATOR
[
Today
at 12:50:41 pm]
Status of FPC 3.4.0 or FP...
by
gidesa
[
Today
at 12:35:41 pm]
Notetask 1.1.1 - Free cro...
by
AlexanderT
[
Today
at 12:00:08 pm]
The Future of FPC
by
Martin_fr
[
Today
at 11:53:35 am]
Fast Canvas Library V1.05...
by
backprop
[
Today
at 11:36:25 am]
How to determine the unkn...
by
CM630
[
Today
at 11:22:22 am]
Lazarus/FreePascal Bug
by
cdbc
[
Today
at 10:52:58 am]
how to enable multihelper...
by
dsiders
[
Today
at 03:35:27 am]
Bee Hive solitaire
by
TBMan
[
Today
at 03:22:09 am]
AI Created Music
by
Tony Stone
[
Today
at 03:02:08 am]
Send form to true left an...
by
mas steindorff
[
Today
at 02:39:34 am]
Help needed compiling
by
jamie
[
Today
at 02:33:02 am]
Free Pascal for a small e...
by
dbannon
[
Today
at 02:24:49 am]
Debian removes FPC/Lazaru...
by
dbannon
[
Today
at 02:09:35 am]
makefiles
by
PascalDragon
[February 12, 2026, 11:37:48 pm]
; after then
by
Curt Carpenter
[February 12, 2026, 11:36:16 pm]
[ANN] fpGUI Toolkit v2.0....
by
Fred vS
[February 12, 2026, 10:45:14 pm]
TRichMemo EM_FORMATRANGE ...
by
AgriMensor
[February 12, 2026, 08:50:07 pm]
fpGUI Toolkit v2.0.1 has ...
by
Roland57
[February 12, 2026, 08:22:06 pm]
[SOLVED] Defining TDBDrop...
by
1HuntnMan
[February 12, 2026, 08:08:22 pm]
Problems in drawing an ar...
by
simsee
[February 12, 2026, 07:52:25 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How can I change brush color in DBGrid? (Read 4276 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: 13353
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