[Delphi] タブ順に処理をする

めんどくさがりなくろねこはシステムの必須入力チェックとフル桁入力チェックは業務入力チェックの前に出来ないかと考えた。
チェックの順番は、当然にタブ順がふさわしい。

タブ順を自分で管理するのはめんどくさい。エンターキーで[Delphi] Enterキーで次のフィールドに移動する の様な処理が出来るんだからきっと何か良い方法がある!
と調べた結果がGetTabOrderListだった。これを使うと単純なチェックはカスタマイズしたコントロールに持たせたチェックで終わらせることが出来そうだ!しかし、この関数いつからあるんだろう?

※TBC~はくろねこ製のオリジナルコンポーネントのメソッドで、CheckRequiredとCheckFillCharはそれぞれ必須入力チェック、フル桁入力チェックである。

procedure TForm1.CheckInputData(Sender: TObject);
var
  i: integer;
  CtrlList: TList;
  ctrl: TWinControl;
begin
  CtrlList := TList.Create;
  try
    GetTabOrderList(CtrlList);
    for i := 0 to CtrlList.Count - 1 do
    begin
      ctrl := CtrlList[i];
      if (ctrl is TBCCustomEdit) then // エディット
      begin
        if not TBCCustomEdit(ctrl).CheckRequired(true) then exit;
        if not TBCCustomEdit(ctrl).CheckFillChar(true) then exit;
      end;
      if (ctrl is TBCCustomComboBox) then // コンボボックス
      begin
        if not TBCCustomComboBox(ctrl).CheckRequired(true) then exit;
      end;
    end;
  finally
    CtrlList.Free;
  end;
end;

コメント (0件)


くろねこ研究所
https://www.blackcat.xyz/article.php/ProgramingFAQ_del0074