?
Solved

Delphi 5 - Can the Enter key behave as the down arrow?

Posted on 2005-03-31
3
Medium Priority
?
731 Views
Last Modified: 2012-06-27
I want the ENTER key to have the same the EXACT same effect as the down arrow in a dbGrid. I tried to change the key variable on the onKeyDown event without success. I am using Delphi 5 and ADO and a series of events is triggered when the dataset scrolls.

Thanks for the help,
Roberto.
0
Comment
Question by:rmaranhao
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 750 total points
ID: 13674554
look here:

http://delphi.about.com/od/vclusing/l/aa012699.htm

procedure TForm1.DBGrid1KeyPress
 (Sender: TObject; var Key: Char);
begin
If Key = #13 Then Begin
 If HiWord(GetKeyState(VK_SHIFT)) <> 0 then begin
  with (Sender as TDBGrid) do
  if selectedindex > 0 then
   selectedindex := selectedindex - 1
  else begin
   DataSource.DataSet.Prior;
   selectedindex := fieldcount - 1;
  end;
 end else begin
  with (Sender as TDBGrid) do
  if selectedindex < (fieldcount - 1) then
   selectedindex := selectedindex + 1
  else begin
   DataSource.DataSet.Next;
   selectedindex := 0;
  end;
end;
Key := #0
end;
end;
0
 
LVL 5

Author Comment

by:rmaranhao
ID: 13674757
This code has the same effect as the side arrow. I do not want to change the selected column


The code I am using is this (onkeypress):

  if key = #13 then
  with Query do
  try
        if State = dsEdit then
          Post;
    Next;
  except
  end;

I moves to the next record but when I use the down arrow the next value is selected. When I use the ENTER key somehow the cursor is after the field value. This forces the user to use backspace to erase the value.

I admit that I have various events that happen during the post and scroll, but everything works great with the down arrow....
0
 
LVL 5

Author Comment

by:rmaranhao
ID: 13674780
key := #0 solved My problem....
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question