Solved

Using Enter Key to switch columns in DBGrid

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

13 Experts available now in Live!

Get 1:1 Help Now