Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paint TStringGrid cells from outside OnDrawCell event, is it possible?

Is there any way to paint specific cells on Delphi's TStringGrid without using the OnDrawCell event, for instance if I click a button the specified cells will be painted depending on their content.

like image 298
Raul Avatar asked Jan 27 '26 02:01

Raul


1 Answers

To keep the painting persistent, the way you should do this is as follows:

  • in the button OnClick event handler, set some data that distinguishes these cells
  • in the same event handler, invalidate the painting area of cells
  • in OnDrawCell event handler do a normal painting for the cells not distinguished
  • in the same event handler, paint your distinguished cells differently

--jeroen

like image 175
Jeroen Wiert Pluimers Avatar answered Jan 28 '26 20:01

Jeroen Wiert Pluimers