David

Thanks for your reply.  I probably made my explanation a bit too brief and left 
out essential info and used misleading terminology.  Each grid column 
represents a room within a Dept and each row a day of a preselected month.  The 
data is got from a single table which contains the date, the aforementioned 
times and information (or no information - empty cell) about each room at a 
particular time of day on a particular date.  The query fetches data for a 
single day, containing 27 rows (there are 27 time slots in a day) and 
cols/fields representing the rooms in the dept. The app loops through (for 
loop) each field in turn (individual rooms) where it enters a while loop 
through each row (the time slots) and increments a count if data is found.  The 
const 27 you see in the code is the total number of time slots in a day.  Three 
constant colours (you are quite right that they should be declared as const) 
are assigned, one for no data found for that room on that day (count=0), one 
for some data but not in all time slots (count > 0 and < 27), and one for data 
found in all time slots for that room on that day (count=27).  Thus for each 
cell in the stringgrid data is got and counted, and a colour is assigned to the 
individual cell based on the value of the count.   

I take your point (and that of Antonis) that the code for getting and 
manipulating data should be kept outside of the OnDraw event.  It'll be a few 
hours before I can get back to the job, but as soon as I can I'll let you know 
what progress has been made.

Regards
Steve 

Your OnDraw event is flawed. First of all, do NOT get the data from within the 
onDraw event! Your only putting code in to handle custom drawing of the control.
    
     You did say "field" so I assume you want to color the columns?. Get rid of 
the for loops since it already loops through each cell. It starts at the top 
left and ends up at the bottom right. Just have it check the column property as 
it goes and color the cell based on that. You could put the color for that 
column in the column tag property. The code to set the color for each column is 
put in the appropriate place outside of this event (button click or whatever). 
You'd have to give each column tag a default property in order for it not to be 
black with ($000000) until your code executes.
  (Tip: defined your cutom colors as a constant at top of form):
   
  constants
    clAmber: TColor($0011FF); <-- only 6 digits for a color!!!
   
  procedure TOverviewForm.SGDrawCell(Sender: TObject; ACol, ARow: Integer;Rect: 
TRect; State: TGridDrawState);
  begin
  Case ACol Of
  0:   color := SG.Column[0].Tag;
  1:   color := SG.Columns[1].Tag;
  etc.
end;
   
   


***************************************************************************
This e-mail and any files transmitted with it are confidential. If you are not 
the intended recipient, any reading, printing, storage, disclosure, copying or 
any other action taken in respect of this e-mail is prohibited and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately by using the reply function and then permanently delete what you 
have received.
Content of emails received by this Trust will be subject to disclosure under 
the Freedom of Information Act 2000, subject to the specified exemptions, 
including the Data Protection Act 1998 and Caldicott Guardian principles.
This footnote also confirms that this email message has been swept by 
MIMESweeper and Sophos Anti-virus for the presence of computer viruses.
***************************************************************************



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to