Re: TZF - Tab - Enter - and Edit Components

Marie Vihonsky <[email protected]> Fri, 06 Feb 2004 12:42:09 -0500
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
Hi Bob,

TzEdit has an 'enter as tab' option  --  TabOnEnter

OR

Set your form's KeyPreview to True then do this

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if (Key = #13) then begin
     SelectNext(ActiveControl as tWinControl, TRUE, TRUE);
     Key := #0;
   end;
end;

If you are using a Grid with Edits on the same form, you need to trap 
both cases separately.

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
    if (Key = #13) then begin
      if ActiveControl <> TzGrid1 then begin
           SelectNext(ActiveControl as tWinControl, TRUE, TRUE);
           Key := #0;
        end;
    end;
end;

procedure TForm1.TzGrid1KeyPress(Sender: TObject; var Key: Char);
var  where : integer;
begin
      if (Key = #13) then begin
        where := tzgrid1.SelectedIndex;
        if where < 7 then
          tzgrid1.SelectedIndex := where + 1
        else begin
          {user in last column - move to first editable}
          tzgrid1.SelectedIndex := 4;
          tznavigator1.btnclick(nbnext);
          if dmod.Results.dEOF then beep;
          tzgrid1.refreshgrid;
        end;
        Key := #0;
      end;
end;

Hope this helps!

Marie

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------