0

I decided to do a little project. It's a work with two-dimensional array, we all know it from Math class. I'd like to color main diagonal in StringGrid by red color in ButtonClick procedure. I know how to find main diagonal with FOR cycle but I don't know how to change the color. Something like example, but it doesn't work.

Stringgrid1.cells[i,j].color:=clRed;

Phil
  • 1
  • Nope, this is not what I want. It's not on button click and I don't believe that I need such a long code to change color in one cell. – Phil Mar 11 '18 at 12:26
  • 1
    Hey sorry to break your bubble, the only way to change cell colour in standard `TStringGrid` is to use the [`OnDrawCellEvent`](http://docwiki.embarcadero.com/Libraries/Tokyo/en/Vcl.Grids.TCustomDrawGrid.OnDrawCell) – whosrdaddy Mar 11 '18 at 12:28
  • So that means I can't change it on ButtonClick? – Phil Mar 11 '18 at 12:34
  • Sure you can, you will have to save state somewhere. You could use the Objects[] property for that. Then you can check that state in the `OnDrawCell` event – whosrdaddy Mar 11 '18 at 12:42
  • I will try to code it, thanks. – Phil Mar 11 '18 at 12:47

0 Answers0