Link to home
Start Free TrialLog in
Avatar of SRP
SRP

asked on

color and saving in stringgrids

I am working on a project in Delphi and  need to use a stringgrid and allow the user to select cells and click a button. The onclick event needs to change the color of selected cells and save the cells coordinates in a file.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SRP
SRP

ASKER

The solution works very well, but I need to change how it works. I need the button click to save the coordinates and color the cell and not the selectcell event. Also is it possible to color the all of the selcted cells?
saving the row/col is easy enough on a button click by saving it in a global var instead then writing the file on the button click..


var
  Form1: TForm1;
   s : string;
implementation

{$R *.DFM}

 procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
  begin
 s := Inttostr(ACol) + Inttostr(ARow);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
writetofile('f:\cells.txt',s);
paint;
end;

end.

the difficult part is painting the selected cells and not using the ondrawcells event,ive never seen code that doesnt use the drawcell event, i had a go but couldnt get that part to work right.
you could try doing nothing on drawcell event and calling stringgrid.repaint on buttonclick but that will only color the selected cell to default blue..maybe thats what you want im not sure..
Avatar of SRP

ASKER

I need the button click to change the cell color, so that it remains colored after it is selected and will always be colored.
hi,
i dunno how to do it so ive re-asked the question on your behalf see:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10240202 

tell me when a suitable answer has been given
cheers.  

ps :
probably best to leave a comment in that question straight away otherwise if someone answers it you may have to pay points to see the answer.