In DBGrid, we output data (from the MSSQL server, from the view), the OnCellClick handler is written, does what is required of it. The problem is this: you need cells that have been "clicked" to paint / delete values ​​/ make font color = background color - no difference. I got to something like this:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then begin with DBGrid1.Canvas do begin Brush.Color:=clWhite; Font.Color:=clWhite; FillRect(Rect); end; end; end; 

However, only the selected cell is filled, after selecting another cell, the fill disappears. How can I save the shading of "clicked" cells?

  • make a list of cells, and when clicked add a cell to this list. in the above procedure, to change the parameters not for the seldected state, I'm checking if the cell is in the list / - teran
  • And if you select the cells with the Ctrl or Shift key pressed and select another cell, the fill will disappear? - androschuk

0