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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.StringGrid1SelectCe ll(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.
var
Form1: TForm1;
s : string;
implementation
{$R *.DFM}
procedure TForm1.StringGrid1SelectCe
ARow: Integer; var CanSelect: Boolean);
begin
s := Inttostr(ACol) + Inttostr(ARow);
end;
procedure TForm1.Button1Click(Sender
begin
writetofile('f:\cells.txt'
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..
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.
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.
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.
ASKER