Link to home
Start Free TrialLog in
Avatar of TomazB
TomazBFlag for Slovenia

asked on

Moving trough components

I have app with a few forms with lot of controls for data input (text or numbers). Is there any simple way to switch amongst them (to make them active) while entering data. Tab is clumsy becouse of large number of controls. I would need something like arrow keys that moves focus to nearest component in any direction. Perhaps someone have code already writen?
Avatar of God_Ares
God_Ares

use setfocus...

edit1.SetFocus;

e.g. you must enter a valid zip in edit1 to go tho the next thing


procedure jada1.OnkeyUp(jadajadajada)
Begin
  if length(edit1.Text)=4 {and ValidateZip(Edit1.text)} then button1.SetFocus;
end;

or with the arrows

procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var   d,e:Tcontrol;
 i:integer;
begin
  if ssShift in shift      then
  Begin
    d := TControl(sender);
    for i:=0 to d.parent.controlcount-1 do
      find best one fitting to key by using d.left en d.top
    e.setfocus;
   if key = vk_up then
  end;
end;

ASKER CERTIFIED SOLUTION
Avatar of God_Ares
God_Ares

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this works great for edit's and memo's
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange