perhaps I sould have tried this first.. ![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
I created a simple type to hold some colours for cells
initalise this (cells all draw cream as you would expect)
draw grid gets the colours from the objects array
Problem is the array dosnt seen to work if (as a test)
I force some values in like this, then examine the test array, all the values are equal to the last element set
in this case Blue. (and all cells draw blue) None are equal to the initalised value.
Must be somthing simple. I just can't see it.
[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
I created a simple type to hold some colours for cells
Code:
type TCellCol = Class(TObject)
BackColour: TColor;
FontColour: TColor;
end;
initalise this (cells all draw cream as you would expect)
Code:
Cellcolour := TCellCol.Create;
Cellcolour.BackColour := ClCream;
Cellcolour.FontColour := ClBlack;
for R := 0 to 1999 do
for c := 0 to 15 do
begin
emergidata.cells[C, R] := inttostr(R);
emergidata.Objects[C, R] := Cellcolour;
end;
draw grid gets the colours from the objects array
Code:
procedure TEmergiForm.emergidataDrawCell(Sender: TObject; Col,
Row: Integer; Rect: TRect; State: TGridDrawState);
var count, r, C: integer;
begin
r := row; // Copy variable 'row' as it only seems to be valid for a short time
C := Col; // yes I know this should not be required for new delphi versions
Count := ((Row - 1) * emergidata.colcount) + Col; // calculate our position in the stringlist
if (count > 0) and (count <= list.count) then
with (sender as tstringgrid) do
begin
if state = [] then // dont overwrite fixed areas
begin
if R = Foundrow then
canvas.brush.color := FindColour
else
if r > 0 then canvas.brush.color := (Objects[c, r] as TCellCol).BackColour;
canvas.fillrect(rect);
canvas.textout(rect.left + 2, rect.top + 2,list.strings[count]);
end;
end;
end;
Problem is the array dosnt seen to work if (as a test)
I force some values in like this, then examine the test array, all the values are equal to the last element set
in this case Blue. (and all cells draw blue) None are equal to the initalised value.
Must be somthing simple. I just can't see it.
Code:
(Emergidata.Objects[1 ,1] as tCellCol).BackColour := clyellow;
(Emergidata.Objects[2, 2] as tCellCol).BackColour:= claqua;
(Emergidata.Objects[3, 3] as tCellCol).BackColour := clgreen;
(Emergidata.Objects[4, 4] as tCellCol).BackColour:= clblue;
inc (Item);
end;
end;
for r:= 0 to 4 do
for c := 0 to 4 do
testarray[c, r] := (emergidata.Objects[c,r] as TCellcol).BackColour;
[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.