Board index » delphi » Tab away from a DBGrid control

Tab away from a DBGrid control

Hello,

When the cursor is in a DBGrid control, is it possible to press the Tab key
to shift focus away from the DBGrid?

Suggestions are most welcome!

 

Re:Tab away from a DBGrid control


<
When the cursor is in a DBGrid control, is it possible to press the Tab key
to shift focus away from the DBGrid?

Quote

Modify or create an OnKeyDown event handler to catch a Key = VK_TAB and set
the focus to the control you want...

{...}
  if Key = VK_TAB then
    MyOtherControl.SetFocus;
{...}

If you don't know which control you want to go to then this won't work.
There might be a way to pass a tab character to the form and have it use
it's own tab order stuff... You might try this...

procedure TMyForm.MyGridKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  {...}
  if Key = VK_TAB then
    SendMessage(TForm(TDBGrid(Sender).Owner).Handle, WM_CHAR, Word(Key), 0);
  {...}
end;

NOTE:  This is all untested, they're just suggestions.

Alex

Re:Tab away from a DBGrid control


procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
  if TDBGrid(Sender).SelectedIndex = MYEXITCOLUMN then
    FindNextControl(Sender, True, True, True);
end;

--
John Elrick
j...@improgrammer.com
www.improgrammer.com

Delphi Application/Component Development
Delphi Mentoring

Quote
liangg <lia...@hkstar.com> wrote in message

news:7m2f9k$hem25@forums.borland.com...
Quote
> Hello,

> When the cursor is in a DBGrid control, is it possible to press the Tab
key
> to shift focus away from the DBGrid?

> Suggestions are most welcome!

Re:Tab away from a DBGrid control


Hi, Liangg.

Look options TDBGrid.Options. There have one subproperty dgTabs: The user
can navigate through the grid using the Tab and Shift+Tab keys.

Regard.

ps. I'm sorry for my very bad English.
--
Petio Tonev
pto...@iname.com
www.i.am/ptonev , www.w3.to/tonevsoft

Other Threads