Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

schedule with stringgrid

Status
Not open for further replies.

niclas73

Programmer
Sep 19, 2005
7
SE
Hi
How do I fill a column rect depending of a value of a variable?

if variable := 6 then fill column(6)

I am trying to make a schedule with a stringgrid where the stringgrid looping out employees with different work times.

The columns I have in the stringgrid is: name, and time columns from 06 to 21

if the employee starts working at 06:00 then a want to fill the “06” rect whit clGreen.

Kind regards
Niclas
 
You can control the appearance of TStringGrid cells by writing an OnDrawCell event handler.

This event is fired every time Delphi/Windows needs to draw a cell.

In the event handler you can choose your background color, font properties, text, position of text within the cell and so on. So your event handler might include code that looks like
Code:
  if (ACol=6) and (variable=6) then
    Canvas.Brush.Color := clGreen
  else
    Canvas.Brush.Color := clWhite;

Remember to set the DefaultDrawing property of the TStringGrid to false.

You might find faq102-3514 helpful as it gives an example of writing an event handler to right justify text in a StringGrid cell.

Andrew
Hampshire, UK
 
Thanks Andrew

Is it possible to fill a rect induvidual depending on a value in the cell (collected from database)? say a cell value is 15 and the widht of the cell is 20, I would like to fill that cell 75% whit green color. I´m trying to create a schedule that displays employees working hours. if he starts at 06.30 then the no 6 cell will be filled by 75% of green color.

Niclas
Hofors, SWE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top