1

呼び出しパラメーターとしてTListboxまたはTChecklistBoxをサポートする関数を作成したい

 MyUISupportFunction ( ......  ; aListBox : TObject);


 if (aListBox as  TObject) is TListBox  then (aListBox as  TListbox).Items.Clear;
 if (aListBox as  TObject) is TCHeckListBox  then (aListBox as  TCheckListbox).Items.Clear;

UI(TListBoxとTChechecklist Box)の両方でより効率的に動作するコードを記述できるのではないかと思います

4

1 に答える 1

7

どちらもTCustomListBoxから継承します

Procedure MyUISupportFunction (aListBox : TCustomListBox);
begin
   aListBox.Items.Clear;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MyUISupportFunction(Listbox1);
  MyUISupportFunction(CheckListBox1);
end;
于 2013-03-26T13:42:17.497 に答える