Solved

DBgrid coloring on var calculated onformshow

Posted on 1998-10-22
3
457 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 50 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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