Simulate the <Enter> key in editable TStringGrid cell

I have a TStringGrid with editable cells (set the options correctly).
Now I want this to happen : when the user encode the = sign in a cell, the <Enter> key should be simulated.
So the user does not have to hit the <Enter> key in that situation
Thanks
LVL 1
LeTayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
Do you want to = sign stays in a cell? if not put OnKeyPress event as:
procedure TForm7.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = '=' then Key := #13; //simualte ENTER
end;

Open in new window


if you want sign = set keyup event:

type
  TStringGridHelper = Class(TStringGrid);

procedure TForm7.StringGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = Ord('0')) and (Shift = [ssShift]) then //= ->  '0' + <shift>
    TStringGridHelper(Sender).HideEditor;
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LeTayAuthor Commented:
Hum, I want this : when the user press the = (equal sign), that value should go into the cell and key presss <Enter> should be done by the application (instead of by the user)
Second proposal does not work, = is not referenced anywhere
0
Sinisa VukSoftware architectCommented:
Can you make small test project with same grid Options. Are you in edit mode when pressing SHIFT+0 (aka '=')?
What happens when you press ENTER? (or want to)
It exit edit mode in my case.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

LeTayAuthor Commented:
Hello, on my keyboard, AZERT Belgium, the = sign is NOT shift-0 !
That's the difference
The = sign is just ... the equal sign without shift
0
Sinisa VukSoftware architectCommented:
so, if you put his code:

procedure TForm7.StringGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   ShowMessage(IntToStr(Key));
end;

Open in new window


what is showed on message in case when press '='?
0
LeTayAuthor Commented:
Found 187
Used now
Works
0
Sinisa VukSoftware architectCommented:
yes, VK_OEM_PLUS when look in this table....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.