getting cell color in a TCRDBGrid

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

getting cell color in a TCRDBGrid

Post by albourgz » Wed 20 Apr 2011 12:38

Hello,

using bcb 2010 / odac 6.90.0.57.
I have a function receiving as parameter a TCRDBGrid, and exporting its content to an excel spreadsheet, works fine.
The cells in the dbgrid have different colors, using the OnDrawColumnCell event.
I would like these colors also to be set in the excel spreadsheet.
I tried setting grid->Col and grid->Row, then using grid->Brush->Color and grid->Canvas->Font->Color to get cell current color, but it doesn't work.

=>Is there a way to know the color of a cell in a T(CR)DBGrid?

Regards.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 21 Apr 2011 12:04

Hello,

Background and font colors should be defined only in the onDrawColumnCell event.
But to determine cells colors, you can use the same algorithm as for color assignment.

albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

not very usable in practise

Post by albourgz » Fri 22 Apr 2011 07:41

I have an app with 100's of grids, all inherited from same form, with an onKeyPress allowing an export to excel, but each form has different DrawColumnCell implementation.

My function receives a grid as param, so I should use
grid->InDrawColumnCell(....) for each cell, then read color properties, but I have to be able to give a rect and a state, it seems difficult. Furthermore, the grid is on screen so I would have to prevent the method to be called when displaying the grid.

Does someone have a better method or know another (inherited) component abel to give this information?
Is this information available in the bcb XE version of TDBGrid?

Regards.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 26 Apr 2011 06:45

Hello,

Our TCRDBgrid (as standard TDBGrid) doesn't save color properties, so yo should manually save them for each DBGrid.
For example, you can create your own DBGrid successor of TcustomDBGrid with the needed functionality.

Post Reply