?
Solved

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

Posted on 2005-03-31
3
Medium Priority
?
725 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

770 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