Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DBgrid coloring on var calculated onformshow

Posted on 1998-10-22
3
Medium Priority
?
459 Views
Last Modified: 2010-04-03
I want to color the cells of my dbgrid depending upon a variable which is calculated in a procedure invoked 'on formshow.' Currently, the 'ondrawcolumncell' event appears to happen before 'onformshow.' I'm looking for a suggestion how to paint the cells based on this calculated variable.

The data doesn't exist when the form is initially created.

I am looking for a suggestion to get the grid colored properly.
0
Comment
Question by:oneeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1343876
oneeye,

hup, q'n already entered... heck, here was my answer :

the ondrawcolumncell normally appears after the onshow event...

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  holdColor: TColor;
begin
  holdColor := DBGrid1.Canvas.Brush.Color; {store the original color}
  if Column.FieldName = 'Species No' then
    if (Column.Field.AsInteger > 90070) then begin
      DBGrid1.Canvas.Brush.Color := clGreen;
      DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      DBGrid1.Canvas.Brush.Color := holdColor;
    end;
end;

Regards, Zif.


0
 

Author Comment

by:oneeye
ID: 1343877
Ah, thank you. Both your answers were very helpful. I do have one additional question, if you could be so kind. Am I correct in assuming that the column drawing method does not page through the records in the table on the draw? What I ended up doing was using as the first column in the dbgrid the variable I calculated as a column 1 pixel wide to set the color of the rest of the columns on that row. This works fine, I was pondering about other more elegant ways of doing this, though.
0
 

Author Comment

by:oneeye
ID: 6968640
Wow,

Sorry I forgot to close out the question.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question