hi, I have a StringGrid, and want the user to type only numbers (integers, floating point), so I defined a test in the OnEditingDone event and test if the input is numerical value, if not, I want to give user a warning, and then set focus & enabling editing state of the offending cell. Here is my EditingDone function:
procedure TfmMCX.sgMediaEditingDone(Sender: TObject);
var
grid: TStringGrid;
val: Extended;
ss: string;
rowid, colid: integer;
begin
grid:= Sender as TStringGrid;
if(grid = nil) then exit;
try
try
ss:=grid.Cells[grid.Col,grid.Row];
rowid:=grid.Row;
colid:=grid.Col;
if(Length(ss)>0) then
val := StrToFloat(ss);
except
raise Exception.Create('Input is not a number!');
end;
except
On E : Exception do
begin
ShowMessage(E.Message);
grid.Row:=rowid;
grid.Col:=colid;
grid.EditorMode:=true;
end;
end;
end;
however, I can only see a warning, but I can not either move the focused cell to the offending one, or enable the editor mode. My StringGrid already has the "goEditing" option enabled.
I am appreciated if you can suggest how to fix this. thanks!