Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
[ solved ] Dbgrid active cell different color
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
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Bad ICONINFO struct in Jw...
by
Madoc
[
Today
at 01:45:41 pm]
Compiler demotes register...
by
Madoc
[
Today
at 01:41:35 pm]
Tpagecontrol descendant
by
dseligo
[
Today
at 01:37:28 pm]
[SOLVED] Combined pointer...
by
CM630
[
Today
at 01:08:17 pm]
F8 step-over sometimes go...
by
Martin_fr
[
Today
at 12:44:27 pm]
Cross compilation error, ...
by
jollytall
[
Today
at 12:41:00 pm]
IsManagedType problem, do...
by
marcov
[
Today
at 12:31:33 pm]
Lazarus character map
by
dseligo
[
Today
at 12:22:41 pm]
Using WebAssemblies
by
Laprado
[
Today
at 12:11:11 pm]
[Solved] Help with sql
by
magleft
[
Today
at 12:08:27 pm]
android
by
BlueIcaro
[
Today
at 11:41:53 am]
Initiaiizing records by c...
by
Molochnik
[
Today
at 11:38:56 am]
Square Fractal: A bit dif...
by
Boleeman
[
Today
at 10:47:20 am]
Here's some Pong game. Su...
by
Seenkao
[
Today
at 10:16:13 am]
lamw
by
dseligo
[
Today
at 09:35:00 am]
"fpc.cfg is missing" (not...
by
Thaddy
[
Today
at 08:55:31 am]
Fairtris 2: The Ultimate ...
by
TRon
[
Today
at 08:48:08 am]
A question on Modula2 vs ...
by
MarkMLl
[
Today
at 08:39:26 am]
Offical launch of the 1 B...
by
Thaddy
[
Today
at 08:37:40 am]
Indeed TCustomApplication...
by
Gustavo 'Gus' Carreno
[
Today
at 08:22:53 am]
Hypocycloid Program (incl...
by
speter
[
Today
at 05:33:19 am]
Designer
by
SandyG
[
Today
at 03:20:24 am]
Best way to exchange data...
by
cdbc
[
Today
at 03:00:24 am]
scanline example
by
speter
[
Today
at 12:12:12 am]
Pack
by
domasz
[March 18, 2024, 10:24:35 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [ solved ] Dbgrid active cell different color (Read 3798 times)
John Landmesser
New Member
Posts: 31
[ solved ] Dbgrid active cell different color
«
on:
September 21, 2017, 04:03:49 pm »
how to use DrawColumnCell to just draw active cell in different color?
must be really simple!!
This code paints the whole active Column but active Cell only?
Code: Pascal
[Select]
[+]
[-]
if
DBGrid
.
SelectedField
.
Index
=
DataCol
begin
TDBGrid
(
Sender
)
.
Canvas
.
Brush
.
Color
:
=
clblue
;
TDBGrid
(
Sender
)
.
Canvas
.
Font
.
Style
:
=
Font
.
Style
+
[
fsBold
]
;
TDBGrid
(
Sender
)
.
Canvas
.
Font
.
Color
:
=
clRed
;
end
;
now searching here:
https://forums.embarcadero.com/thread.jspa?threadID=253161&tstart=0
«
Last Edit: September 21, 2017, 07:26:11 pm by John Landmesser
»
Logged
wp
Hero Member
Posts: 11833
Re: Dbgrid active cell different color
«
Reply #1 on:
September 21, 2017, 04:17:48 pm »
Don't use OnDrawColumnCell, you'd have to draw everything by yourself. Application of the OnPrepareCell event is much simpler: it is called immediately before the cell is painted, all canvas properties already have been set, but in this event you can override them; a set of parameters comes with the event to decide which cell is painted.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
DBGrid1PrepareCanvas
(
sender
:
TObject
;
DataCol
:
Integer
;
Column
:
TColumn
;
AState
:
TGridDrawState
)
;
begin
if
(
[
gdSelected
,
gdFocused
]
*
AState <>
[
]
)
and
(
DBGrid1
.
SelectedColumn
=
Column
)
then
begin
DBGrid1
.
Canvas
.
Brush
.
Color
:
=
clRed
;
DBGrid1
.
Canvas
.
Font
.
Color
:
=
clWhite
;
end
;
end
;
Logged
John Landmesser
New Member
Posts: 31
Re: Dbgrid active cell different color
«
Reply #2 on:
September 21, 2017, 07:25:29 pm »
thats's it, works perfect, thanks wp :-)
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
[ solved ] Dbgrid active cell different color
TinyPortal
© 2005-2018