Is it possible to change the pen used to draw the border around specific squares in a colorGrid? I have a grid with 85 columns and 60 rows, filled with colors. Subsequently, I need to "highlight" certain cells - and I think the best way to do this is to change the color of the cell's border? Possible?
Regards,
Rick
Another ColorGrid question
Hi, Rick.
Not individual cell border. But you can get the same result by manually drawing rectangle over the selected cell in tChart OnAfterDraw event.
Not individual cell border. But you can get the same result by manually drawing rectangle over the selected cell in tChart OnAfterDraw event.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Hi, Rick.
You could try using something along these lines:
The example does not actually check if XInd and ZInd are inside valid values .. you can add this and extend the code.
You could try using something along these lines:
Code: Select all
function HighlightRect(Series: TCustom3DGridSeries; XInd, ZInd: Integer): TRect;
begin
With Series do
begin
Result.Left := CalcXPos(XInd);
Result.Right := CalcXPos(XInd+1);
Result.Top := GetVertAxis.CalcPosValue(ZValues.Value[GridIndex[XInd+1,ZInd+2]]);
Result.Bottom := GetVertAxis.CalcPosValue(ZValues.Value[GridIndex[XInd+1,ZInd+1]]);
end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var R: TRect;
begin
r := HighlightRect(Series1,3,2);
With Chart1.Canvas, Chart1 do
begin
Brush.Style := bsClear;
Pen.Color := clRed;
Pen.Width := 2;
Inc(R.Left,Pen.Width div 2);
Inc(R.Top,Pen.Width div 2);
ClipRectangle(ChartRect);
Rectangle(R);
UnclipRectangle;
end;
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Hi Marjan,
I checked out this code. It almost works with two issues:
1. The calculation of the right coordinate in the HightRect function is returning the same value as left. It seems to need scaling somehow. In the exampe I have if I add 1 thru 3 to XIND it continues to return the same as the left coordinate. If I add 4 to it it returns the correct value. In this case 4 is the number of ticks between values on the X axis.
2. If I change the brush style to bsSolid, and set a color, as in:
brush.style := bsSolid;
brush.Color := clGreen;
I would expect a solid color of green inside the rectangle and a red border. It remains white.
Thnks,
Rick
I checked out this code. It almost works with two issues:
1. The calculation of the right coordinate in the HightRect function is returning the same value as left. It seems to need scaling somehow. In the exampe I have if I add 1 thru 3 to XIND it continues to return the same as the left coordinate. If I add 4 to it it returns the correct value. In this case 4 is the number of ticks between values on the X axis.
2. If I change the brush style to bsSolid, and set a color, as in:
brush.style := bsSolid;
brush.Color := clGreen;
I would expect a solid color of green inside the rectangle and a red border. It remains white.
Thnks,
Rick