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
Solved

Using Enter Key to switch columns in DBGrid

Posted on 1998-12-03
2
251 Views
Last Modified: 2012-05-04
How can I use the <Enter> key to switch
to next columns inside DBGrid?
0
Comment
Question by:davichoi
2 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1349174
hi davichoi,

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBTables, Grids, DBGrids;

type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    Table1: TTable;
    DataSource1: TDataSource;
    procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = 13 then key := 9;
end;

end.

Regards, Zif.
0
 

Author Comment

by:davichoi
ID: 1349175
Thanks for you answer. But I use the <Tab> to switch to the other controls, so I have desabled the <Tab> key in the
DBGrid->Options.

I used the following codes to let <Enter> key to act like <Tab> key with ordenary controls to switch to each other in the KeyDown Event:

If Key = vk_Return Then
      PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);

It worked very well. In case do you know how to do the samething with Windows API to achieve the same funcionality?

Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

789 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