就是输入页面中,我输入了一个DBEDIT中的内容后按回车后,光标就到下个DBEDIT
解决方案 »
- delphi中canvas对象在哪儿呀,我找不到
- 我用windows.beep(100,200)为什么编译器告诉我[Error] Undeclared identifier: 'windows'
- 我想做一个按钮,将dbgrid中的数据另存为execl中,请问代码该怎么写呢?谢谢!
- 使用fastreport,在报表中如何使用Band
- delphi 做通信是否有前途
- DELPHI连接ORACLE的问题。
- delphi中利用串口发送数据的问题
- 自动移动输入焦点!
- 如何写这个类
- 如何取到 WINNT\SYSTEM32 这个目录的绝对路径?
- 如何用des算法实现字符串的正确加解密.
- 如果不让针式打印机空走纸?
procedure TForm1.FormKeyDown(Sender: TObject ........);
begin
case Key of
VK_RETURN: Perform(wm_nextdlgctl, 0, 0);
end;
end;
if key=13 then
if activecontrol is tedit then
selectnext(activecontrol,true,true);
然后把窗体的keypreview属性设为true
if Key = 13 then SetFocusControl(DBEdit2);
有N个DBEdit就要写N个吗?
begin
if Key = 13 then SetFocusControl(DBEdit2);
end;cprocedure TForm.DBEdit2OnKeyPress(......);
begin
if Key = 13 then SetFocusControl(DBEdit3);
end;procedure TForm.DBEdit3OnKeyPress(......);
begin
if Key = 13 then SetFocusControl(DBEdit4);
end;procedure TForm.DBEdit4OnKeyPress(......);
begin
if Key = 13 then SetFocusControl(DBEdit5);
end;//...........
if Key = 13 then SetFocusControl(DBcombobox);
????
procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview := True;
end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_RETURN: Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview := True;
end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_RETURN: Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 103
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnKeyDown = FormKeyDown
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 56
Top = 16
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
end
object Edit2: TEdit
Left = 200
Top = 16
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit2'
end
object Edit3: TEdit
Left = 72
Top = 80
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit3'
end
object Edit4: TEdit
Left = 216
Top = 48
Width = 121
Height = 21
TabOrder = 3
Text = 'Edit4'
end
object Edit5: TEdit
Left = 64
Top = 144
Width = 121
Height = 21
TabOrder = 4
Text = 'Edit5'
end
object Edit6: TEdit
Left = 216
Top = 112
Width = 121
Height = 21
TabOrder = 5
Text = 'Edit6'
end
end
在主窗体中定义一个过程
procedure TMain_Form.DoEnterAsTab(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_KEYDOWN then
begin
if Msg.wParam = VK_RETURN then
Keybd_event(VK_TAB, 0, 0, 0);
end;
end;
在FormCreate中这么引用
Application.OnMessage := DoEnterAsTab;