Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DBCtrlGrid Navigation

307 views
Skip to first unread message

Errol Croy

unread,
Jun 8, 1999, 3:00:00 AM6/8/99
to
Hi All,

I have a keypress event in my form that causes the Enter key to act as
Tab. Works great for the whole form except for the controls in a
DBCtrlGrid. Any tips, help, etc. appreciated.

Regards,
Errol

ultf...@my-deja.com

unread,
Jun 8, 1999, 3:00:00 AM6/8/99
to
In article <375D17...@ccc.xo.com>,

Hi,
I have the same problem. I'm trying to figure out how to use the
Dokey procedure to change the Key operation. Currently the Return key
will toggle the EditMode. If you Discover anything Please let me know.

Kevin (KBo...@MacKayISO.com)


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Joselito G. Real

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
Errol Croy <Er...@ccc.xo.com> wrote in message
news:375D17...@ccc.xo.com...

> I have a keypress event in my form that causes the Enter key to act as
> Tab. Works great for the whole form except for the controls in a
> DBCtrlGrid. Any tips, help, etc. appreciated.

DBCtrlGrid has its own way of handling the OnKeyDown event and what I did is
I trap the OnKeyDown event within a DBCtrlGrid. If the user presses the up
arrow key (VK_Up), the down arrow key (VK_Down), etc..., it does what I
want, try it. Now my DBCtrlGrid behaves like a regular grid in terms of
keystrokes. I also included the tab to enter key behavior like so:

procedure TForm2.DBCtrlGrid1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
case Key of
VK_Prior : DBCtrlGrid1.Dokey(gkPageUp); ///go page up staying on the
same field
VK_Next : DBCtrlGrid1.Dokey(gkPageDown); ///go pagedown staying on the
same field
VK_Up : DBCtrlGrid1.Dokey(gkUp); ///go up one record staying on the
same field
VK_Down : DBCtrlGrid1.Dokey(gkDown); ///go down one record staying on
the same field
VK_Return,VK_TAB: Key:=VK_TAB; ///tab to enter, go to next field
end;
end;


You may also have to look at the OnKeyPress or OnKeyDown event of those
controls in a DBCtrlGrid and look if they do something else. Sometimes, some
of your components may interfere with the OnKeyDownEvent of DBCtrlGrid and
you should either override them with your own event handler for each of the
component or exempt them from the OnKeyDown event of your DBCtrlGrid by
using the exit procedure. This way, if the child component has its own way
of handling the Onkeydown event, it gets handled first. I have several
InfoPower components within the DBCtrlGrid and they have their own peculiar
way of handling the OnKeyDown event and to take care of those, here's an
example:

procedure TForm2.DBCtrlGrid1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if ServiceCodeCB.DroppedDown then exit;
if CustomerCB.Grid.Visible then exit;
if CustomerIDCB.Grid.Visible then exit;
if MerchantCB.Grid.Visible then exit;
if AcctTypeCB.DroppedDown then exit;
if ResubmitCB.DroppedDown then exit;

case Key of
VK_Prior : DBCtrlGrid1.Dokey(gkPageUp);
VK_Next : DBCtrlGrid1.Dokey(gkPageDown);
VK_Up : DBCtrlGrid1.Dokey(gkUp);
VK_Down : DBCtrlGrid1.Dokey(gkDown);
VK_Return,VK_TAB:
begin
if AcctTypeCB.Focused then begin
wwDBEdit5.SetFocus;
Abort; exit;
end;
if wwDBEdit5.Focused then begin
ResubmitCB.SetFocus; Abort; exit;
end;
if ResubmitCB.Focused then begin
AcctTypeCB.SetFocus; abort; exit;
end;
Key:=VK_TAB;
end;
end;
end;

Errol Croy

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
Joselito,

This is excellent help! I won't forget the effort that you have expended
in giving me such a good clear example. Thanks a million.

Errol

0 new messages