Solved

Using Enter Key to switch columns in DBGrid

Posted on 1998-12-03
2
244 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now